Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM graphql API: 'Access-Control-Allow-Origin' header is not present on the graphql API

Avatar

Level 2

Hi Team,

When I try to hit the graphql API in publish domain, the 'Access-Control-Allow-Origin' header is not showing. I can see this header in normal pages.
but only not coming in graphql API url. Could anyone please help me in this issue.

I have followed below tutorial. But no luck.
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/d...

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@kamsdurai You need to cors related config in your vhost file, esp allowing the "origins" from where you are trying to make GraphQL query and remove the "origin" header from the request before sending it to Publish instance. Check the example given here 

 

https://github.com/adobe/aem-guides-wknd/blob/main/dispatcher/src/conf.d/available_vhosts/wknd.vhost

 

# Developer Localhost
SetEnvIfExpr "env('CORSProcessing') == 'true' && req_novary('Origin') =~ m#(http://localhost(:\d+)?$)#" CORSTrusted=true
   # Remove Origin before sending to AEM Publish
        RequestHeader unset Origin

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@kamsdurai You need to cors related config in your vhost file, esp allowing the "origins" from where you are trying to make GraphQL query and remove the "origin" header from the request before sending it to Publish instance. Check the example given here 

 

https://github.com/adobe/aem-guides-wknd/blob/main/dispatcher/src/conf.d/available_vhosts/wknd.vhost

 

# Developer Localhost
SetEnvIfExpr "env('CORSProcessing') == 'true' && req_novary('Origin') =~ m#(http://localhost(:\d+)?$)#" CORSTrusted=true
   # Remove Origin before sending to AEM Publish
        RequestHeader unset Origin

 

Avatar

Administrator

@kamsdurai  Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni