#Root returns 404 on Vercel with appDirectory

20 messages · Page 1 of 1 (latest)

fervent ridge
#

Everything was working until I migrated to appDirectory.

On local with npm run dev and npm start it works.

When I build and deploy on Vercel, / returns 404! I can get the homepage by typing /index.

How can I make / work again?

fervent ridge
vale spire
fervent ridge
#

@vale spire I would like to understand why on local it works but not on Vercel? Super odd! How would you suggest that I can link / to /index?

vale spire
#

this is an example i used before

#

async redirects() {
return [
{
source: "/",
destination: "/welcome",
permanent: true,
},
];
},

#

add to your nextjs config file

#

your source will be /

#

destination will be /index

fervent ridge
#

I am confused to what does Vercel do differently than running next start locally?

#

Thank you @vale spire

vale spire
#

I dont really faced a problem like this before, but what Im doing is redirecting or adding a useEffect hook to my main component that route.pushes to the source that I want

vale spire
fervent ridge
#

I renamed page.tsx that was mapping to /index and added it to /home/page,tsx so I have it on /home then I configured the redirects as you suggested in next.config.js to map / to /home

#

Thanks @vale spire !

#

It still doesn't resolve the original weird behaviour

vale spire
#

yeah but you can coniniue development anyways 😅😅

fervent ridge
#

Yes, but I am having lots of situations where local behaviour is different than deployed behaviour.

fervent ridge
#

Basically you need to remove form next.config.js the following:

  i18n: {
    locales: ['en'],
    defaultLocale: 'en',
  },

And the default route start working again on Vercel