Help

CORS issue with Custom App

Topic Labels: Custom Extensions
1818 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Dominik_Fischer
5 - Automation Enthusiast
5 - Automation Enthusiast

Hey! I’m currently making the first steps with the Blocks SDK and having problems with fetching data from our Shopify Backend.

I’m trying to do it like this (frontend.js):
let url = https://xyz.myshopify.com/admin/api/2020-01/orders/${record.getCellValue("Shopify Id")}
let response = await fetch(url,{
method: ‘GET’,
headers: {
‘Content-Type’: ‘application/json’,
‘X-Shopify-Access-Token’: ‘xyz’,
},
})
return await response.json()

Whenever I trigger this function, the console logs say:
Access to fetch at 'https://xyz.myshopify.com/admin/api/2020-01/orders/123.json' from origin 'https://devblock---123xyz.airtableblocks.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

Any help with this will be much appreciated :slightly_smiling_face:

1 Reply 1
Eugene_Kim
6 - Interface Innovator
6 - Interface Innovator

Hi @Dominik_Fischer ,

I don’t know if the Shopify API is intended to be accessed from the browser. Shopify seems to be limiting the origins that the request can be made from if you’re dong it from the browser. I suggest making a request to a server of yours and having that server make the Shopify API request.