Skip to content

CSP middleware does not work properly #3844

Description

@predaytor

reproduction repo: https://github.com/predaytor/fresh-project-csp-middleware-bug

import { csp } from "fresh";

// nonce missing but header set
// app.use(csp({ useNonce: true }));

app.get('/', (ctx) => {
    return ctx.render(
        <html>
            <head>
                <style>{'body { color: red; }'}</style>
            </head>
            <body>
                <h1>Hello</h1>
            </body>
        </html>,
    );
});

// works, but `content-security-header` is not set
app.use(csp({ useNonce: true }));

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