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..
Hey, I’m having an issues retrieving data from glue in the newest version. All other requests im usi
Hey,
I’m having an issues retrieving data from glue in the newest version. All other requests im using are working fine. But when I try to get the checkout-data, I get the following error:
Access to XMLHttpRequest at '<http://glue.de.spryker.local/checkout-data>' from origin '<http://localhost:8080>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I already tried changing the config to allow cross site requests, but that didn’t help.
$config[GlueApplicationConstants::GLUE_APPLICATION_CORS_ALLOW_ORIGIN] = '<http://localhost:8080>';
Furthermore I noticed, that the response I’m getting contains the access-control-allow-origin header, but doesn’t contain the access-control-allow-methods.
The response itself is:
{"errors":[{"detail":"Missing access token.","status":403,"code":"002"}]}
I’m using fetch to make the requests.
I would be grateful for any help.
Comments
-
Hi!
So you are requesting
/checkout-data
from localhost:8080 and the config has$config[GlueApplicationConstants::GLUE_APPLICATION_CORS_ALLOW_ORIGIN] = '<http://localhost:8080>';
And get the cors error or missing token error?
0 -
access-control-allow-methods
will be returned onOPTIONS
request to the endpoint0 -
I’m requesting the data from http://glue.de.spryker.local with code similar to this:
fetch('<http://glue.de.spryker.local/checkout-data>')
The request is coming from localhost:8080 that’s why I put it in the config.
Do I need to send an additional request for theaccess-control-allow-methods
?0 -
are you sure you sent POST request?
checkout-data
will only allow POSTs regadless of the CORS settings.0 -
Yes I am.
Here is the code im using:var body = { "data": { "type": "checkout-data", "attributes": { "idCart": "dc69d182-21cb-5916-935b-4cba70ff47ab" } } } await fetch(process.env.VUE_APP_ROOT_API + '/checkout-data', { method: 'POST', headers: this.getAuthenticationHeader(), body: JSON.stringify(body), }) .then((response) => response.json()) .then((response) => { console.log('Response:', response); }) .catch((error) => { console.error('Error:', error); });
And here is the request header, chrome shows:
OPTIONS /checkout-data HTTP/1.1 Host: [glue.de](http://glue.de).spryker.local Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Access-Control-Request-Method: POST Origin: <http://localhost:8080> Access-Control-Request-Headers: authorization,content-type Accept: */* Referer: <http://localhost:8080/> Accept-Encoding: gzip, deflate Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
0 -
does it fail with access token or cors error?
I also checked default OPTIONS response headers and the method are there for me 🤔
0 -
I’m not quite sure. In the console I get the following messages:
0 -
But when I look at the request itself, the response is:
{"errors":[{"detail":"Missing access token.","status":403,"code":"002"}]}
0 -
are you running spryker in docker?
0 -
Yes I am
0 -
I’d check the
$config[GlueApplicationConstants::GLUE_APPLICATION_CORS_ALLOW_ORIGIN]
is really configured correctly for docker.
Still I wonder how it would give 403 for the OPTIONS.0 -
I added the config value to the config_default-docker and confirmed that the value is used. That’s whats confusing me too. It’s possible that the error isn’t in my Spryker configuration but in the way I’m sending the request. But I don’t really have an idea what the cause could be
0 -
Do you have true or false for ssl in the deploy file?
ssl: enabled: false
I had such an error as missing access token trying to access http when ssl was true in docker.
0 -
In my deploy file ssl is disabled for docker
0 -
@ULW0Z4150 The fact that other endpoints works just fine but this one - is weird. I would go debugging
\Spryker\Glue\GlueApplication\Controller\OptionsController::resourceOptionsAction()
But I suspect that break-point won’t even hit there. This method is supposed to handle OPTIONS request.
0 -
Also, have a look at \Spryker\Glue\GlueApplication\GlueApplicationConfig::getCorsAllowedHeaders() and make sure that you’re not sending any headers that are not allowed by CORS policy config
0 -
☝ that really looks like the case you described:
0 -
…so debug this guy:
\Spryker\Glue\GlueApplication\Rest\Request\HttpRequestValidator::validateAccessControlRequestHeader()0 -
Thanks for your advice. I’ll see what I can find out
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 78 Spryker News
- 936 Developer Corner
- 793 Spryker Development
- 90 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
- 27 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
- 33 Product & Business Questions
- 69 Spryker Safari Questions
- 50 Random