Local endpoint are not being called

My endpoints are not called internally but testing it in local everything works only on vercel the local endpoints are not being called, if i call them by myself they work but not from the api

const res = await fetch(${process.env.VERCEL_URL ? https://${process.env.VERCEL_URL} : process.env.ROOT_URL}/api/user);

for example this works on the local but not on the vercel (env is correctly setup)

Hi, @notzer0two!

const res = await fetch(${process.env.VERCEL_URL ? https://${process.env.VERCEL_URL} : process.env.ROOT_URL}/api/user);

This looks correct. However, the fact that it works locally but not on Vercel may mean that there are some configuration issues or environmental differences.

You said that your environment is fine, but just make sure that both VERCEL_URL and ROOT_URL are correctly set in your Vercel project settings. Keep in mind that VERCEL_URL might have different values in preview deployments versus production deployments.

If process.env.VERCEL_URL is undefined in production for some reason, your code will fall back to process.env.ROOT_URL. Make sure this isn’t set to a localhost URL in your production environment.

Do you have any errors or logs that you could look at for pointers?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.