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: configurable CORS origin response #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

birme
Copy link
Contributor

@birme birme commented Feb 2, 2023

This PR resolves #30

Copy link

@martinstark martinstark left a comment

Choose a reason for hiding this comment

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

Not a full review, but some thoughts

lib/route-helpers.ts Outdated Show resolved Hide resolved
return responseHeaders;
if (allowAnyOrigin) {
responseHeaders['Access-Control-Allow-Origin'] = '*';
} else if (allowedOrigins.includes(origin)) {
Copy link

@martinstark martinstark Feb 2, 2023

Choose a reason for hiding this comment

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

I think parsing the string as an array probably isn't needed, String also has an includes function:

"someOrigin,anotherOrigin".includes("someOrigin")

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.

Configurable CORS origin header
2 participants