Skip to content

Support for Mixed SSG and SSR Mode with Dynamic Nonce Handling in nuxt-security #665

@alexbidenko

Description

@alexbidenko

We have a scenario in Nuxt where certain pages are statically generated (SSG), while the rest of the site runs in SSR mode or another runtime rendering mode. Currently, the nuxt-security module computes SHA hashes for scripts and styles on these static pages and injects them via a meta tag in the Content Security Policy.

The problem is that in a mixed environment like this, these hashes might not account for all scripts and styles that would be present if the page were purely SSR. Essentially, since we still have a running Node process serving SSR content, it would be more flexible to dynamically inject a correct nonce for scripts and styles at runtime, as if the page were fully SSR.

In other words, instead of relying on static meta tags for CSP hashes, we’d want nuxt-security to use HTTP headers and dynamically provide the nonce. That way, even for partially pre-generated static pages, the nonce is always correct and consistent.

The question is whether this can currently be configured, and if not, is it possible to add this feature to the module?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions