You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We’ve encountered an issue with CORS configuration in MedusaJS where the OPTIONS preflight request is incorrectly expecting the x-publishable-api-key header. According to CORS specifications, preflight requests (OPTIONS) should not require authentication or custom headers to be sent by the client. Currently, the server responds with a 403 error if this header is omitted in OPTIONS requests, which breaks legitimate cross-origin requests.
This issue blocks frontend clients from properly integrating with the API, as browsers automatically handle preflight and do not attach custom headers like x-publishable-api-key to OPTIONS requests.
Could you please adjust the CORS configuration to exclude enforcing x-publishable-api-key for OPTIONS methods? This would align with standard CORS practices and resolve the preflight failures.
Let me know if you need additional details or examples. Thanks for your hard work!
Expected behavior
The OPTIONS method should not require the x-publishable-api-key header.
The header should only be validated in subsequent actual requests (GET, POST, etc.) after a successful preflight.
Actual behavior
The server enforces the presence of the x-publishable-api-key header in OPTIONS requests.
If the header is missing, the server returns a 403 Forbidden error, blocking the preflight request.
This prevents browsers from proceeding with the actual request (e.g., GET or POST) even when valid credentials are provided in subsequent steps.
Link to reproduction repo
no
The text was updated successfully, but these errors were encountered:
I'm facing the same issue, are you trying to use the cart module by any chance? I can't use any of the cart endpoints because of CORS error but I've properly added the x-publishable-api-key and set the correct domains on STORE_CORS and AUTH_CORS.
I haven't been able to find a workaround for this, the only thing I haven't tried yet is using a JWT token but if OPTIONS is expecting a header that won't be there first then I'm not sure if it will make any difference ☹️
Package.json file
Node.js version
21
Database and its version
16.2
Operating system name and version
Windows
Browser name
No response
What happended?
We’ve encountered an issue with CORS configuration in MedusaJS where the OPTIONS preflight request is incorrectly expecting the x-publishable-api-key header. According to CORS specifications, preflight requests (OPTIONS) should not require authentication or custom headers to be sent by the client. Currently, the server responds with a 403 error if this header is omitted in OPTIONS requests, which breaks legitimate cross-origin requests.
This issue blocks frontend clients from properly integrating with the API, as browsers automatically handle preflight and do not attach custom headers like x-publishable-api-key to OPTIONS requests.
Could you please adjust the CORS configuration to exclude enforcing x-publishable-api-key for OPTIONS methods? This would align with standard CORS practices and resolve the preflight failures.
Let me know if you need additional details or examples. Thanks for your hard work!
Expected behavior
The OPTIONS method should not require the x-publishable-api-key header.
The header should only be validated in subsequent actual requests (GET, POST, etc.) after a successful preflight.
Actual behavior
The server enforces the presence of the x-publishable-api-key header in OPTIONS requests.
If the header is missing, the server returns a 403 Forbidden error, blocking the preflight request.
This prevents browsers from proceeding with the actual request (e.g., GET or POST) even when valid credentials are provided in subsequent steps.
Link to reproduction repo
no
The text was updated successfully, but these errors were encountered: