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

Array - set origin -Not working #294

Open
Naveenvuedata opened this issue Dec 12, 2022 · 3 comments
Open

Array - set origin -Not working #294

Naveenvuedata opened this issue Dec 12, 2022 · 3 comments

Comments

@Naveenvuedata
Copy link

Trying to use Array - set origin to an array of valid origins from subdomains , but it is not working

Example:

@FredrikOseberg
Copy link

Trying to use Array - set origin to an array of valid origins from subdomains , but it is not working

Example:

Your regex targets example2.com. This will not work when your domain is example.com. You need to change the domain you are performing the request from to match the regex.

@Naveenvuedata
Copy link
Author

Trying to use Array - set origin to an array of valid origins from subdomains , but it is not working
Example:

Your regex targets example2.com. This will not work when your domain is example.com. You need to change the domain you are performing the request from to match the regex.

Yes, try to Implement the same way that you are saying by trying to add example.com in the regex /.example.com$/

But still not working

Expected: CORS should allow all subdomains (sub1.example.com , sub2.example.com) under the main domain example.com

If you have done pls share me piece of code for my understanding

@enov
Copy link

enov commented Jul 26, 2023

When using an Array or Regex, the header will appear only when there is an allowed match with the request's Origin header:

https://github.com/expressjs/cors/blob/master/lib/index.js#L58

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

No branches or pull requests

3 participants