medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
25.02k stars 2.5k forks source link

CORS BLOCKED - Access to XMLHttpRequest at. No 'Access-Control-Allow-Origin' #5560

Closed Sylvesterx1 closed 11 months ago

Sylvesterx1 commented 11 months ago

Admin working Storefront issue.

When I access directly to link API in browser I see correct json result: https://api.aray.pl/store/product-categories

{"count":5,"offset":0,"limit":100,"product_categories":[{"id":"pcat_pants","created_at":"2023-11-05T12:17:49.508Z","updated_at":"2023-11-05T12:17:49.508Z","name":"Pants","description":"","handle":"pants","parent_category_id":null,"rank":0,"category_children":[],"parent_category":null},{"id":"pcat_shirts","created_at":"2023-11-05T12:17:49.508Z","updated_at":"2023-11-05T12:17:4..

But from storefront in log console not possible fetch data from api endpoints to store:

foreach return error: Access to XMLHttpRequest at 'https://api.aray.pl/store/product-categories' from origin 'https://aray.pl' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sylvesterx1 commented 11 months ago

Resolved by add in .env store cors with https

shahednasser commented 11 months ago

You can learn more about setting the CORS options in our documentation. Will close this issue as it's resolved.