Vercel & CORS Problem
Does anyone know how to configure CORS on Vercel with SolidStart? I keep getting...
Access to fetch at 'https://my-vercel-url.app/api/todos/get-todos' from origin 'http://localhost:3000' has been blocked by CORS policy: 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 I've Tried 1. I tried adding a
vercel.json
file at the root of my project: https://vercel.com/guides/how-to-enable-cors#enabling-cors-using%C2%A0vercel.json
2. I've tried adding headers to my API endpoint:
3. I've set my server to "vercel" in app.config.ts
And nothing.
Any help would be appreciated.
ChrisHow to Enable CORS on Vercel
Learn how to enable CORS in a single Node.js Serverless Function, in a Next.js app, and using vercel.json.
2 Replies
Is it a single app (both frontend & backend) on Vercel? If so why is it referencing
localhost:3000
? Sounds like you are trying to call the vercel app from a local app.The app on vercel is acting as a backend for mobile devices.
I added the app to Netlify and everything worked perfectly. It must be something to do with Vercel’s servers.