A developer is encountering CORS errors when sending requests from a Shopify theme extension to their local Node.js development server (exposed via ngrok).
Initial Problem:
Method mismatch between client (GET) and server (POST/GET)
CORS headers incorrectly set on client instead of server
Proposed Solutions:
Configure CORS middleware on the server side (using packages like cors for Express/Koa)
Add mode: "cors" to the fetch request
Include "ngrok-skip-browser-warning": "69420" header to bypass ngrok’s browser warning
Set Access-Control-Allow-Origin header from server, preferably with specific domain instead of wildcard “*”
Current Status:
The original poster switched to another project before testing the solutions, so the issue remains unresolved. The thread later diverges into related questions about integrating Shopify public apps with theme extensions and retrieving shop URLs in backend middleware.
Summarized with AI on November 18.
AI used: claude-sonnet-4-5-20250929.
The “Access-Control-Allow-Origin” header needs to be set by your server, not your client.
You’re using the POST method on your server but GET on the client.
For problem #1, you need to set that header from your server. It looks like you’re using Koa or Express. Use a package like this one: https://expressjs.com/en/resources/middleware/cors.html. It’ll configuration the CORS headers based on what you need. Using “*” is wide open… if you can, I’d recommend using the domain of your clients.
For problem #2, make sure the method in your fetch call matches the method you’ve set on your route.
async function cookieTest() {
fetch(${url}api/auth/cookieTest, {
method: “get”,
headers: headers,
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((err) => console.log(err));
}
if useful marks as like and accept solution
@RyanMacdonald could you please help me. How to get shop url in node and react app in backend or serversde. I want shop url in ndex.js or middlewre? I am calling this api but failed to get shop url here