CORS error with Preview deployment URLs #5490
Replies: 1 comment 2 replies
-
Had the same issue here, I disabled deployment protection for the project and it worked. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Hi,
I have a backend that accepts certain explicit origins.
Now Vercel's deployment preview URLs are all different and I'd like to avoid having to add each deploy URL to the list of allowed origins on the backend but instead have a way to allow for origins using a wildcard which follows the pattern for deployment preview URLs:
<project-name>-<unique-hash>-<scope-slug>.vercel.app
How could I go about achieving this?
Example
No response
Steps to Reproduce
Here's a bit of the backend code:
I get a
400 CORS Missing Allow Origin
on theOPTIONS
preflight request and aNS_ERROR_DOM_BAD_URI
on the subsequentPOST
request.In the Firefox console, I get:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at {BACKEND_URL}. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 400.
andCross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at {BACKEND_URL}. (Reason: CORS request did not succeed). Status code: (null).
In the Chrome console, I get:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Any help much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions