NextJS (next.config.js) redirects not working

At some point (not sure when, just noticed yesterday), all of my NextJS redirects (in next.config.js) stopped working on Netlify. I tried building/serving locally via netlify serve and they do not work locally either.

Running the NextJS server locally works.

site name: unityescaperooms.netlify.app
recent buildID: 646daf3db6055000087fa2cd
dependency versions:
@netlify/plugin-nextjs: v4.37.2
next: v13.4.3

I’ve manually verified that my redirects() function in next.config.js returns the following:

[
  {
    source: '/',
    has: [{ type: 'query', key: 's' }],
    destination: '/search',
    permanent: true
  },
  {
    source: '/team-building',
    destination: '/events/team-building',
    permanent: true
  },
  {
    source: '/birthday-party',
    destination: '/events/birthday-party-celebration',
    permanent: true
  },
  {
    source: '/events/birthday-party',
    destination: '/events/birthday-party-celebration',
    permanent: true
  },
  {
    source: '/team-building',
    destination: '/events/team-building',
    permanent: true
  },
  {
    source: '/privacy-policy',
    destination: '/legal/privacy-policy',
    permanent: true
  },
  {
    source: '/terms-of-service',
    destination: '/legal/terms-of-service',
    permanent: true
  },
  { source: '/contact-us', destination: '/contact', permanent: true },
  {
    source: '/the-toy-shop',
    destination: '/redlands/soul-shop',
    permanent: true
  },
  {
    source: '/infection',
    destination: '/redlands/infection',
    permanent: true
  },
  { source: '/jobs', destination: '/careers', permanent: true },
  { source: '/brand', destination: '/brand/overview', permanent: true },
  {
    source: '/killers-lodge',
    destination: '/rancho-cucamonga/killers-lodge',
    permanent: true
  },
  {
    source: '/kitchen-nightmare',
    destination: '/rancho-cucamonga/kitchen-nightmare',
    permanent: true
  },
  {
    source: '/person-of-interest',
    destination: '/rancho-cucamonga/person-of-interest',
    permanent: true
  },
  {
    source: '/soul-shop',
    destination: '/redlands/soul-shop',
    permanent: true
  },
  {
    source: '/the-cabin',
    destination: '/redlands/the-cabin',
    permanent: true
  },
  {
    source: '/tomb-of-pharaoh',
    destination: '/rancho-cucamonga/tomb-of-pharaoh',
    permanent: true
  },
  {
    source: '/wizard-escape',
    destination: '/redlands/wizard-escape',
    permanent: true
  }
]

None of these redirects work. e.g.
Team Building and Corporate Events - Unity Escape RoomsTeam Building and Corporate Events - Unity Escape Rooms
Careers - Unity Escape RoomsCareers - Unity Escape Rooms
Wizard Escape - Redlands - Unity Escape RoomsWizard Escape - Redlands - Unity Escape Rooms

I know this used to work, but I’m not sure at what point it stopped working.

I do not use _redirects, but I do have a single [[redirect]] declaration in my netlify.toml (to address this previous issue)

Hi @eoneill, thanks for the post.
If you have not read the blog post below already about Nextjs redirects and rewrites on Netlify, Kindly do so to see if it helps.

Thanks.

1 Like