Comments (23)
@rahulblue you can make this work by using the cloud UI for managing ENV settings.
The relevant document would be:
https://devdocs.magento.com/guides/v2.3/config-guide/prod/config-reference-var-name.html
You'll need to set
env:CONFIG__SYSTEM__WEB__GRAPHQL__CORS_ALLOWED_ORIGINS
as well as other relevant configuration in the UI.
from magento2-cors.
Additionally, I would recommend giving 2.0 a try as well, it's ~10x faster than the 1.x line.
from magento2-cors.
env:CONFIG__SYSTEM__WEB__GRAPHQL__CORS_ALLOWED_ORIGINS
I have tried using this method but again having a same problem
.
from magento2-cors.
Please re-read the documents I sent.
from magento2-cors.
Exactly which point are you referring to the problem is in there is no .magento.env.yaml file in the setup, only way I have that creating environment variable from Cloud UI, but it is not working. I am researching this topic since from last 9 hour still do not have exact solution.
from magento2-cors.
Additionally, take a look at your screenshot and try to align:
- What you wrote in the variable name
- What you pasted into the variable value
- What I wrote in the docs for the variables of this repo
It looks like you literally copy-pasted some access control headers into the field, which I don't mention anywhere in my docs.
from magento2-cors.
Thanks for your reply,
Can you see below screenshot? Am I missing or doing wrongly?
please suggest.
from magento2-cors.
@rahulblue looks much better, however there's an error in your key name DEFAUT
vs. DEFAULT
from magento2-cors.
No luck after updating.
from magento2-cors.
Ok, let me try this out and I'll post my findings.
from magento2-cors.
please let me know your findings, I have only one hope which is your extension. for Magento cloud integration branch there is no other way to enable CORS settings, it would be enable on further environment(Staging and Production) due to fastly. currently it is a biggest bottleneck for moving ahead to me.
Thanks.
from magento2-cors.
@damienwebdev any update on this one? Having the same issue here
from magento2-cors.
from magento2-cors.
@damienwebdev I'm working on a cloud project right now.
Our stack is Angular (Frontend) and Magento Cloud.
We are getting issues with CORS while trying to fetch data from a graphql endpoint.
I've installed your module and tried to configure it:
-
Environment variables:
-- CONFIG__DEFAULT__WEB__GRAPHQL__CORS_ALLOWED_ORIGINS
-- CONFIG__DEFAULT__WEB__GRAPHQL__CORS_ALLOWED_METHOD -
Adding to the app/etc/config.php (we don't have access to the env.php in Magento Cloud)
-
Adding the XML paths directly into the core_config_data table
None of the steps above works
Any other clue on what we could do?
from magento2-cors.
Can you include the output headers on an OPTIONS request with curl targeted at your domain?
curl https://DOMAIN.com/graphql \
-X OPTIONS \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: content-type" \
-H "Origin: https://DOMAIN.com" \
--head
Please change the domain above and post the response you get back.
Additionally, please post the content you used for your ENV settings.
Finally, if you have a local env, can you confirm if it works locally in your environment. It may well be that Fastly messes with requests in cloud.
from magento2-cors.
@damienwebdev just to let you know, I figured it out.
In order for this module to work with Magento Cloud, we need to add the following entries to the app/etc/config.php file:
'system' => [
'default' => [
'web' => [
'graphql' => [
'cors_allowed_origins' => '*',
'cors_allowed_methods' => 'GET, POST, OPTIONS, PUT',
'cors_allowed_headers' => 'Content-Type, GraphQLAuth', // All headers used in the request
'cors_max_age' => '86400',
'cors_allow_credentials' => 0
],
'api_rest' => [
'cors_allowed_origins' => '*',
'cors_allowed_methods' => 'GET, POST, OPTIONS',
'cors_allowed_headers' => 'Content-Type, GraphQLAuth' // All headers used in the request,
'cors_max_age' => '86400',
'cors_allow_credentials' => 0
]
]
]
]
from magento2-cors.
What wound up being the problem, the allowed headers?
from magento2-cors.
yep, those 3 headers must exist:
- cors_allowed_origins
- cors_allowed_methods
- cors_allowed_headers
from magento2-cors.
@leandrofreireasco ok. Then, for the origins, I assume you added those as ENV variables to the cloud UI? Could you add a screenshot of what you added? (Feel free to obfuscate this, I just need a screenshot for the documentation)
from magento2-cors.
pinging @leandrofreireasco just one more time in hopes of a screenshot :)
from magento2-cors.
Funny you mention "for the documentation", I literally see no documentation to use this with Cloud. Trying to piece together a couple random issues with no solutions isn't working. Uninstalled as fast as I installed it.
from magento2-cors.
Sorry @amcguireweb I don't have any merchants that use this on Commerce Cloud. If you're willing to hop in discord, I'd be happy to turn whatever comes out of that into docs, it's just hard to write docs for something I don't do!
from magento2-cors.
Here we go @damienwebdev
app/etc/config.php
.magento.app.yaml
from magento2-cors.
Related Issues (17)
- docs(readme): missing link to packagist package HOT 5
- feat(rest): extend support for rest API calls with header provides. HOT 1
- testing(integration): the integration tests do not currently pass.
- docs(security): add documentation around why the "*" should generally be recommended against.
- [FEAT] Support "Vary: Origin" header
- [FEAT] Add Magento 2.4 support HOT 6
- ci(all): add ci pipeline to run unit and integration tests HOT 7
- feat(cors): add support for Access-Control-Allow-Credentials
- [BUG] Preflight Requests are missing their CORS headers when using Varnish
- Magento Rest Options Error HOT 6
- feat(cors): add support for Access-Control-Expose-Headers HOT 2
- [PERF] Skip Default Magento Code For Requests
- feat(cors): add configurability around per resource rest api/graphql endpoints
- [FEAT] Support "wildcard-like" subdomain of a given origin HOT 6
- [DOCS] Document usage in Commerce Cloud
- Using Varnish Cache with PWA Stuido HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magento2-cors.