Redirects in prod are not building the same as in local dev

Hi all,

Im new to Vercel and nextJs so bear with me please.

I have a small question hope you guys can help:

when generating the redirects as an async function im not seeing the same behavoir in local-dev as in prod.

Im curious to know if the build inside vercel is the same in the pipeline as in local, and im wondering what can I do to easily fix this


Current behaviour in dev wiith prod config npm run build && npm run start

Current behaviour in vercel

... some code

const redirects = async () => {
  const redirectData = await fetchRedirectData() //async call from CMS

  console.log('redirectData', redirectData) // this is undefined in prod vercel but works locally and in dev/staging also hosted in vercel

  return redirectData
    ? [...MANUAL_REDIRECTS, ...redirectData]
    : [...MANUAL_REDIRECTS]
}

const NextConfig = {
  reactStrictMode: false,
  images: { domains: ['storage.rystadenergy.com', 'www.datocms-assets.com'] },
  redirects,
}

module.exports = NextConfig

It looks like the redirect data isn’t being returned from the CMS call. Is there a missing environment variable?

Thanks for anwering,

No I don’t think we are missing, we can interact with the rest of the CMS content.

Strange part is that redirects async function does not wait for const assignation inside the block.

Since it’s fetching the redirect info from the CMS, a dynamic redirect option may be a better fit.