Environment variables for REST API and GraphQL headers for Adobe Commerce Cloud #89
-
Can someone paste a few working examples of the headers required for Adobe Commerce Cloud? I tried all options below but am still getting the CORS error while CONFIG__DEFAULT__WEB__API__REST__CORS_ALLOW_CREDENTIALS: 1 |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
those look correct to me. I've confirmed that this works: CONFIG__DEFAULT__WEB__GRAPHQL__CORS_ALLOWED_HEADERS='content-type, store, authorization, x-magento-cache-id, x-recaptcha' |
Beta Was this translation helpful? Give feedback.
-
Can you Additionally, if there's an error in your browser's console, can you post that as well? |
Beta Was this translation helpful? Give feedback.
-
Here is the OPTIONS request. The response is a HTTP Code 200 Here is the POST request that runs after the OPTIONS request Console log: |
Beta Was this translation helpful? Give feedback.
-
@git-hari-j please post the response headers of both requests. your error indicates that the post request would never be run since |
Beta Was this translation helpful? Give feedback.
-
I think the issue is two separate things: CONFIG__DEFAULT__WEB__API__REST__CORS_ALLOWED_ORIGIN: *
CONFIG__DEFAULT__WEB__API__REST__CORS_ALLOW_CREDENTIALS: 1
CONFIG__DEFAULT__WEB__API__REST__CORS_ALLOWED_METHODS: GET, POST, OPTIONS, HEAD should be: CONFIG__DEFAULT__WEB__API_REST__CORS_ALLOWED_ORIGIN: *
CONFIG__DEFAULT__WEB__API_REST__CORS_ALLOW_CREDENTIALS: 1
CONFIG__DEFAULT__WEB__API_REST__CORS_ALLOWED_METHODS: GET, POST, OPTIONS, HEAD Specifically, Additionally, from your request headers, you also need: CONFIG__DEFAULT__WEB__API_REST__CORS_ALLOW_HEADERS: content-type, store |
Beta Was this translation helpful? Give feedback.
-
I tried a simple request in my local environment: curl --location --request OPTIONS 'https://localhost:59128/rest/default/V1/directory/currency' \
--header 'Origin: http://localhost:4200' I used the env settings: CONFIG__DEFAULT__WEB__API_REST__CORS_ALLOWED_ORIGIN: *
CONFIG__DEFAULT__WEB__API_REST__CORS_ALLOWED_METHODS: GET, POST, OPTIONS And my response headers were:
|
Beta Was this translation helpful? Give feedback.
-
Just FYI. Even after making all changes suggested, nothing worked. I then updated the app/etc/env.php on the cloud instance with the following |
Beta Was this translation helpful? Give feedback.
Just FYI. Even after making all changes suggested, nothing worked. I then updated the app/etc/env.php on the cloud instance with the following
.....
'system' => [
'default' => [
'catalog' => ['search' => ['engine' => 'opensearch', 'opensearch_server_hostname' => 'http: //opensearch.internal', 'opensearch_server_port' => 9200]],
'web' => [
'graphql' => [
'cors_allowed_origins' => '',
'cors_allowed_methods' => 'GET, POST, OPTIONS',
'cors_allowed_headers' => 'content-type, store, authorization, x-magento-cache-id, x-recaptcha',
'cors_max_age' => '86400',
'cors_allow_credentials' => 1,
],
'api_rest' => [
'cors_allowed_origins' => '',
'cors_allowed_methods' => 'GET, POST, OPTIONS',
'cors_allow…