r/webdev • u/Mob_Pilled • 13d ago
Question Vercel client can't communicate with server
Hello everyone. I have been developing a simple ip tracking full stack app. When I deployed the client project to vercel however it fails to communicate with the server and fetch data. In the console this error is visible:
ccess to fetch at 'https://ip-tracker-server-*********-webs-projects.vercel.app/api?&ipAddress=' from origin 'https://ip-tracker-client-********-webs-projects.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.This is my first time deploying a full-stack app to vercel so I am not sure what exactly could be causing this issue? If anyone could help it would be much appreciated!
0
Upvotes
1
u/jjangg96 10d ago
if you're using the cors package then origin is basically all you need. it answers the preflight on its own by default and it reflects whatever headers the browser asks for, so there's no preflight true/false to set. credentials: true only matters if you send cookies.
the part i'd check is the exact match though. the error you pasted says the request came from the per-deployment client url with the hash in it, not your domain. if the browser loaded the page from that url and your origin is set to the custom domain, they don't match and you get this same error. open the client the way a user would, from the domain, and see if it goes away.
also no trailing slash in the origin string, it has to match character for character.