Skip to content
Discussion options

You must be logged in to vote

Ok, I i've found a solution for this. It seems the CSP docs hold a clue:
https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy

We recommend ignoring matching prefetches (from next/link) and static assets that don't need the CSP header.

Use the missing array in the Middleware config to only run the Middleware when the given headers are missing. Example:

export const config = {
  matcher: [
    /*
     * Match all request paths except for the ones starting with:
     * - api (API routes)
     * - _next/static (static files)
     * - _next/image (image optimization files)
     * - favicon.ico (favicon file)
     */
    {
      source: '/((?!api|_next/sta…

Replies: 9 comments 22 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@milovangudelj
Comment options

Comment options

You must be logged in to vote
1 reply
@DDTORRES055
Comment options

Comment options

You must be logged in to vote
4 replies
@milovangudelj
Comment options

@jvandenaardweg
Comment options

@louisthomaspro
Comment options

@jvandenaardweg
Comment options

Comment options

You must be logged in to vote
13 replies
@MisterJimson
Comment options

@cpotey
Comment options

@sylvesteraswin
Comment options

@GXM245
Comment options

@dimitrisnl
Comment options

Answer selected by leerob
Comment options

You must be logged in to vote
2 replies
@peperoli
Comment options

@Mohamed3on
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@EL-MEHDI-ESSAADI-ON
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
Converted from issue

This discussion was converted from issue #37728 on June 15, 2022 22:27.