AEM graphql API: 'Access-Control-Allow-Origin' header is not present on the graphql API | Community
Skip to main content
New Participant
November 30, 2023
Solved

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

  • November 30, 2023
  • 2 replies
  • 1540 views

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/deployments/configurations/cors.html?lang=en

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Saravanan_Dharmaraj

@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

 

2 replies

kautuk_sahni
Employee
January 8, 2024

@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
Saravanan_Dharmaraj
Saravanan_DharmarajAccepted solution
New Participant
January 5, 2024

@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