AEM graphql API: 'Access-Control-Allow-Origin' header is not present on the graphql API | Adobe Higher Education
Skip to main content
Level 2
November 30, 2023
Respondido

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

  • November 30, 2023
  • 2 respostas
  • 1546 Visualizações

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

 

Este tópico foi fechado para respostas.
Melhor resposta por 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 Respostas

Saravanan_Dharmaraj
Community Advisor
Community Advisor
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

 

kautuk_sahni
Community Manager
Community Manager
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