Skip to content

Better Next.js nonce support #547

@jerelmiller

Description

@jerelmiller

Unfortunately, extraScriptProps does not solve the CSP nonce problem for apps with mix of static and dynamic pages.

In a typical Next.js App Router setup, ApolloNextAppProvider is rendered inside a client Providers component mounted from the root layout. To pass a per-request nonce via extraScriptProps, the app has to read the x-nonce header in that layout.

However, reading headers in a layout makes that layout and all nested routes dynamic in Next.js. This means there is currently no practical way to use extraScriptProps for a per-request nonce without making the whole subtree under that layout dynamic.

Originally posted by @maximkuzminykh in #401

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions