CORS Issue

I Am getting a CORS issue when trying to access my CMS. My GraphQLClient looks like so:

       url: '',
       headers: {
           "Authorization": "Bearer ACCESS_KEY",
           'Access-Control-Allow-Origin': '*',
           'Access-Control-Allow-Methods': 'GET,HEAD,OPTIONS,POST,PUT',
           'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
           'mode': 'no-cors'

and the error that I am getting is the following:

Access to fetch at '' from origin 'https://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.

I have tried to follow this documentation: Access-Control-Allow-Origin - HTTP | MDN

Nothing works for me :confused:

Hello @nicole.lopez and welcome to the community!

It seems like the URL for the client is wrong, as the endpoint should be instead of

You can read more about this here: Content Delivery API - API Endpoints - DatoCMS Docs

Hello! Thank you so much! That solved the CORS error, thank you!

1 Like