Next.js Discord

Discord Forum

Rewrites from index not working?

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
I am using page routing and Next 14 and would like to rewrite all paths to a sub path based on some condition (e.g. if a header is present). This works in general, but accessing / does not trigger rewrite. Is there something I'm missing?

async rewrites() {
      return [
        {
          source: '/:path*',
          destination: '/sub-path/:path*',
          has: [
            {
              type: 'header',
              key: 'some-header',
            },
          ],
        },
      ];
    },

0 Replies