Skip to content

fix: csp headers for index pages#2593

Merged
mburri merged 3 commits into
mainfrom
fix/csp-headers-for-index-pages
Jul 9, 2026
Merged

fix: csp headers for index pages#2593
mburri merged 3 commits into
mainfrom
fix/csp-headers-for-index-pages

Conversation

@mburri

@mburri mburri commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

No CSP Header was set for index pages, e.g. https://visualize.admin.ch/en

Pages with more than one path segment included the correct headers: https://visualize.admin.ch/en/imprint

The cause was that the matcher in middleware.ts was is recompiled for i18n routing during the build. The newly generated matcher did only match routes with at least two path segments, e.g. /en/imprint, but not /en itself.

It is not known to me whether upgrading next.js would fix this too.


  • [ x ] I added a CHANGELOG entry
  • [ x ] I made a self-review of my own code

@mburri mburri requested a review from hupf July 1, 2026 07:53
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
visualization-tool Ready Ready Preview, Comment Jul 9, 2026 6:50am

Request Review

@hupf hupf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. As the Next.js + i18n combo is causing this behavior, it may be useful to check the header in an E2E test, to catch when the behavior changes again...

Verify that the middleware correctly sets Content-Security-Policy
headers on locale-root pages (/en) and content pages (/en/imprint),
covering the fix in 848a098.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mburri mburri merged commit 851cbf0 into main Jul 9, 2026
12 checks passed
@mburri mburri deleted the fix/csp-headers-for-index-pages branch July 9, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants