What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hello#help Iam trying to set up the react app example from the documentation but i keep getting the
Hello#help Iam trying to set up the react app example from the documentation but i keep getting the CORS error for /guest-cart s. can somebody tell me where exactly i need to set the access-control-allow-origin and access-control-allow-credentails headers. i tried setting them in docker/generator/src/templates/nginx/http/glue.server.conf.twig but that did not help. some of the CORS exceptions were fixed but the one from /guest-carts never goes away.
Comments
-
Hi Moe, it seems like the “allow-credentials” header is missing.
To verify that this is the problem, I can suggest one dirty hack you can try locally.
Please add the following to your public/Glue/index.php:if (strtoupper($_SERVER['REQUEST_METHOD']) === 'OPTIONS') { header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Headers: origin, accept, authorization, accept-language, access-control-allow-methods, access-control-allow-origin, content-type, x-anonymous-customer-unique-id'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS, PATCH, DELETE'); header('Content-Type: text/plain'); header('Content-Length: 0'); http_response_code(204); exit(0); }
If that would solve the issue, and you can confirm that
Access-Control-Allow-Credentials
- then the right way to solve it would be:
1. Please report the problem to Spryker so we can fix that internally
2. Have a look at \Spryker\Glue\GlueApplication\Rest\Response\ResponseHeaders - this is where the headers are being built; This class is extendable via plugins, so what you would need to do is to implement \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\FormatResponseHeadersPluginInterface where you would add your missing header
I hope that helps0 -
Thank you @UKJSE6T47 . That helped!. iam able to load the app by making the changes to index.php. i will try to make the changes by implementing the pluginInterface..
0 -
Great, thanks for the feedback @U019GT49XKQ
Please let me know eventually - whether the issue was with the missing header inResponseHeaders
part..0 -
..and just to remind again - changing the public/Glue/index.php - is a quick dirty hack, it must not be treated as a recommended solution 🙂
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random