Next.js Discord

Discord Forum

Rewrite root url based on headers

Unanswered
Grass Carrying Wasp posted this in #help-forum
Open in Discord
Grass Carrying WaspOP
I'm trying to rewrite the root URL based on the presence of a header, it works for any path, but can't seem to get it to work for the root path:

  rewrites: async () => ({
    afterFiles: [
      {
        locale: false,
        source: '/:path*',
        has: [
          {
            type: 'header',
            // key: 'X-Magento-Tags-Pattern',
            key: 'x-magento-tags-pattern',
          },
        ],
        destination: '/api/varnish-purge',
      },
    ],
  }),


Works: curl http://127.0.0.1:3000/blabla -H "X-Magento-Tags-Pattern: joejoe"
Doesn't work: curl http://127.0.0.1:3000/ -H "X-Magento-Tags-Pattern: joejoe"
Doesn't work: curl http://127.0.0.1:3000 -H "X-Magento-Tags-Pattern: joejoe"

Ideas how to solve this?

0 Replies