In Magento Cloud hosting, how to add following configuration,
Header set Access-Control-Allow-Origin a.com
When I login to Magento Cloud I have only read access to the server files. Is there a way to do this.?
In Magento Cloud hosting, how to add following configuration,
Header set Access-Control-Allow-Origin a.com
When I login to Magento Cloud I have only read access to the server files. Is there a way to do this.?
I would suggest installing the below module via the composer
https://github.com/graycoreio/magento2-cors/blob/master/docs/stories/configuring-the-headers.md
and apply those configurations in the app/etc/config.php
'system' => [
'default' => [
'web' => [
'graphql' => [
'cors_allowed_origins' => 'https://www.graphql.com, https://www.myotherallowedorigin',
'cors_allowed_methods' => 'POST, OPTIONS',
'cors_allowed_headers' => '',
'cors_max_age' => '86400',
'cors_allow_credentials' => 1
],
'api_rest' => [
'cors_allowed_origins' => 'https://www.restapi.com, https://www.myotherallowedorigin',
'cors_allowed_methods' => 'GET, POST, OPTIONS',
'cors_allowed_headers' => '',
'cors_max_age' => '86400',
'cors_allow_credentials' => 0
]
]
]
]
Cheers!
With Magento Cloud, depending on whether the environment you are looking at has Fastly or not, there could be different solutions.
Global solution
You can use Magento itself to set that header - by creating an extension to set the desired header on all/some of the responses.
NGINX solution
I believe the engineering team can help by raising a support ticket to instruct them to config the NGINX instruction to set this header.
Fastly solution
This is only applicable if the environment you are referring to has Fastly integrated. Since we don’t have direct access to out Fastly account. You will have to config the add header instruction into custom VCL yourself via API call with provided Fastly API credentials. Or raise a support ticket with Magento Cloud to help you setting this custom VCL.
More information regarding Fastly configuration API: https://docs.fastly.com/api/config