CORS blocked my redirection when trying to athorize with OAuth

CORS blocked my redirection when trying to athorize with OAuth

AnisBRANDLY
Shopify Partner
4 0 0

Hello everyone, English is not my native language so please be kind 😉 

 

I am building an external Shopify application. I have a register menu that when I click on register button should send a get request to my server on ('/auth?shop=myShopName.myshopify.com) and then on this, the authentification will begin with beginAuth Shopify api method. At the end of the method, I have a res.redirect to the link returned by beginAuh which is (https://myShopName.myshopify.com/admin/oath/authorize?client_id=*******&scope=write_products%2Cwrite...) but I get a CORS error :

```

Access to fetch at 'https://myShopName.myshopify.com/admin/oath/authorize?client_id=*******&scope=write_products%2Cwrite...' (redirected from 'http://localhost:3000/auth?shop=myShopName.myshopify.com') 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.

```

 

What can I do to solve this? Thanks all!

Replies 2 (2)

studioqdesigns
Excursionist
15 0 7

Hi – I think my team is having a similar issue. Were you able to solve this?

AnisBRANDLY
Shopify Partner
4 0 0

Hey, I just added 'method' : 'no-cors' in my request options.