Script Tag - CORS error when trying to GET data from my app

Highlighted
Astronaut
1085 178 213

Overview
I have a custom REST API within my Koa server and I can access it just fine within my Shopify app using react. However, when I try to access it from my Script Tag, I get a CORS error. 

Issue
I can't access my custom REST API data from the script tag, but I can access it from Postman & my React app.

What I tried
1. Install koa/cors and set {origin: *}

Please help me out if you can. Thank you!

proof2.jpgproof1.jpg

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes
Highlighted
Shopify Staff
Shopify Staff
1041 140 165

Can you share a snippet of your Koa app where you configure CORS?

0 Likes
Highlighted
Astronaut
1085 178 213

Hello,

Thanks for the reply. I actually ended up finding a solution, the reason was simply because the koa-cors middleware was not before the other middlwares. For anyone who comes across this issue, here is the question and answer on stackoverflow.


◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Hire me! Recommended by 25+ customers on Facebook. Click here to read their reviews.
◦ Contact me at: diego.boarutto.fortes@gmail.com
0 Likes