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

Regex in CORS? #2556

Closed
SaadBazaz opened this issue Nov 6, 2022 · 6 comments
Closed

Regex in CORS? #2556

SaadBazaz opened this issue Nov 6, 2022 · 6 comments

Comments

@SaadBazaz
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to deploy the storefront on Vercel, with the backend hosted on a custom server.

Since, during the build process, the frontend makes requests for static/server side, there are CORS errors which cause it to fail.

I want to temporarily set the CORS to any (i.e. *). Doesn't work.

Describe the solution you'd like
Regex-based CORS. e.g.:
*.vercel.app (so that I can safely deploy to Vercel for testing).

Describe alternatives you've considered
Listing each and every possible domain in Vercel, but that isn't a good solution.

@srindom
Copy link
Collaborator

srindom commented Nov 10, 2022

Unfortunately, doesn't look like this is possible: https://stackoverflow.com/questions/18439340/using-a-regular-expression-with-cors

@srindom srindom closed this as completed Nov 10, 2022
@SaadBazaz
Copy link
Author

The SO thread gives a pretty interesting solution. Plus, since Medusa is based on Express, there must be a package which handles this well.

Also, even * (ANY) would work for testing, but that doesn't seem to work either...

@olivermrbl
Copy link
Contributor

I believe @adrien2p has built a potential workaround in #1935. @adrien2p have you test your changes in a prod. + local env?

@adrien2p
Copy link
Member

adrien2p commented Nov 10, 2022

@srindom @olivermrbl I ve built this #1935 which i tested locally and I think some community members tested the pr for their needs as well.

But it is not a workaround it is a proper feature of the cors package, i ve linked the implementation in the description 😅

@SaadBazaz
Copy link
Author

Lgtm. When can we get this bros

@olivermrbl
Copy link
Contributor

My apologies for the wording here @adrien2p. Did not mean to indicate that it was not the right implementation! 😅

@SaadBazaz Will be included in the next release coming out later this week or early next 👍

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

4 participants