Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add callback for configuring Vary header #318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gl-jkeys
Copy link

Fixes #317

This PR adds a callback (shouldSetVaryHeader) to the options which is used to determine when and how to configure the Vary header.

To preserve backward compatibility with all existing cors usages, this callback returns true by default.

If this PR is accepted, I will add documentation to the README on how to use this PR's functionality.

@UlisesGascon
Copy link
Member

I enabled the CI to run in this PR 👍

test/test.js Outdated
return true
}

if (req.originalUrl.startsWith('/images') && header === 'Origin') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node 0.10 failures are due to lack of .startsWith this language feature came in with ES6 in Node 6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (req.originalUrl.indexOf('/images') === 0 && header === 'Origin') {

indexOf should work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to omit Vary: Origin header
4 participants