Next.js Discord

Discord Forum

next.config.js headers based on missing query parameters doesn't work. Is it me?

Answered
American black bear posted this in #help-forum
Open in Discord
Avatar
American black bearOP
Hi! With the following config, the headers apply even if I have a query parameter ?p= in the URL. I'm testing this in dev mode, I didn't test in a production build, yet.

const nextConfig = {
  async headers() {
    return [
      {
        source: '/course/:name/:chapter/:lesson*',
        missing: [
          {
            type: 'query',
            key: 'p',
          },
        ],
        headers: [
          {
            key: 'Cross-Origin-Embedder-Policy',
            value: 'require-corp',
          },
          {
            key: 'Cross-Origin-Opener-Policy',
            value: 'same-origin',
          },
        ],
      },
    ]
  },
}
Answered by American black bear
The issue was on 13.1.1, is currently fixed in 13.5.4, but only if the query has a value other than empty string, which is a bug in my mind.
View full answer

1 Reply

Avatar
American black bearOP
The issue was on 13.1.1, is currently fixed in 13.5.4, but only if the query has a value other than empty string, which is a bug in my mind.
Answer