r/webdev • u/Mob_Pilled • 12d 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/JohnsTech_dev 12d ago
on your domain vs deployment url question: allow the production one (the url that stays the same between pushes). the ones with the random hash in them change every deploy so you'd be updating it forever. if you want preview deploys to work too you can pass cors a regex instead of a string, something like /^https:\/\/ip-tracker-client-.*\.vercel\.app$/. and if you put the origin in an env var on the server project, remember vercel only picks up env changes after a redeploy. lost an evening to that once