Back to Next Js

Custom Routes must return an array

errors/routes-must-be-array.mdx

16.2.5599 B
Original Source

Why This Error Occurred

When defining custom routes an array wasn't returned from either headers, rewrites, or redirects.

Possible Ways to Fix It

Make sure to return an array that contains the routes.

Before

js
module.exports = {
  async rewrites() {
    return {
      source: '/feedback',
      destination: '/feedback/general',
    }
  },
}

After

js
module.exports = {
  async rewrites() {
    return [
      {
        source: '/feedback',
        destination: '/feedback/general',
      },
    ]
  },
}