Cors error react - graphql | Community
Skip to main content
Level 2
December 5, 2022
Solved

Cors error react - graphql

  • December 5, 2022
  • 1 reply
  • 2406 views

I am unable to consume response from AEM to React application.

React App - AEM Headless Example | Adobe Experience Manager

Access to fetch at 'http://localhost:4504/content/graphql/global/endpoint.json' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

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 sathyaprakash

I am able to consume response with help of below configuration

 

Adobe Granite CSRF filter - Excluded path 

Add cutom graphql endpoint - for example - /content/_cq_graphql/myproject/endpoint.json

 

 

1 reply

krati_garg
Adobe Employee
Adobe Employee
December 5, 2022

Hi @sathyaprakash 

Please check below link to configure your CORS policy and Sling Refferer Filter on AEM to enable GraphQL Endpoints accessible to external application

https://www.albinsblog.com/2021/10/how-to-deliver-headless-content-through-graphql-api-and-content-fragments-in-aem.html#.Y43LD3ZBw2z:~:text=Consume%20GraphQL%20API%20Data%20from%20External%20System%3A

 

sathyaprakashAuthorAccepted solution
Level 2
December 6, 2022

I am able to consume response with help of below configuration

 

Adobe Granite CSRF filter - Excluded path 

Add cutom graphql endpoint - for example - /content/_cq_graphql/myproject/endpoint.json

 

 

krati_garg
Adobe Employee
Adobe Employee
December 13, 2022

@sathyaprakash @kautuk_sahni 
Can you please mark the correct answer, so people would know the result of this query.