Did you try it by running by hosting urls somewhere
I hosted my app on a VPS and I am getting the cors error
Topic summary
Core Issue:
Developers encounter CORS errors when making requests from Shopify themes or extensions to Remix-based Shopify apps during local development, particularly when using app proxies or tunnels.
Primary Solution (Posts 4, 17, 19-20):
- Install
remix-utilspackage and use itscors()function - Handle OPTIONS preflight requests explicitly in both
loaderandactionfunctions - For older Remix templates: Add
serverDependenciesToBundle: [/^remix-utils.*/]toremix.config.js - For Vite-based templates: No config changes needed
Key Implementation Pattern:
if (request.method === 'OPTIONS') {
return await cors(request, json({ status: 200 }));
}
const response = json({ data });
return await cors(request, response);
Important Caveats:
- CORS errors typically occur when hosting on VPS/production servers, not with Cloudflare tunnel URLs during development
- App proxy may not work in local development but functions correctly when deployed
- For checkout extensions: Use
authenticate.public.checkout(request)instead ofauthenticate.admin(request) - Session tokens require clicking the app in store admin at least once to initialize
Status: Multiple users confirmed the solution works after properly handling OPTIONS requests in loader functions.