The wizard's CSP change leaves the assets host out of connect-src, so session replay and surveys never start
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 57/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- next.js, typescript
- Área
- developer-experience, security
Línea de trabajo
The issue points to the CSP guidance and review check associated with #1439 (cm#245, cm#278), but does not name their files. Start by locating those guidance and review-check entries, then trace how they build or validate connect-src. Done means the assets host is included there and the review check accepts it; verify against the reported /array/<token>/config request.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I ran the setup wizard (3.0.0) on my Next.js 16 app, which builds a nonce-based Content-Security-Policy in src/server/csp.ts. The policy already allowed the API host in connect-src, and the wizard added the assets host to script-src and a worker-src, like this.
- script-src 'self' 'nonce-…' 'strict-dynamic'
+ script-src 'self' 'nonce-…' 'strict-dynamic' https://eu-assets.i.posthog.com
connect-src 'self' https://eu.i.posthog.com
+ worker-src 'self' blob:
Events were coming in, so everything looked fine, but session replay, surveys, web vitals and dead clicks never started. posthog-js 1.454.2 loads its remote config with fetch() from the assets host (https://eu-assets.i.posthog.com/array/<token>/config), so it falls under connect-src, and the browser blocks it without anything showing up in the console. The run summary didn't mention the CSP either.
I think this comes from the CSP guidance in #1439 (cm#245, cm#278), which puts the API host in connect-src and the assets host only in script-src.
To reproduce it I made one page without any framework, served with the same directives.
// `npm i posthog-js && node repro.mjs`, then open http://localhost:4777 (wizard's policy) and http://localhost:4777/nocsp
import { readFileSync } from "node:fs";
import { createServer } from "node:http";
const TOKEN = process.env.POSTHOG_TOKEN ?? "<project token>";
const nonce = "dGVzdG5vbmNl";
const csp = [
"default-src 'self'",
`script-src 'self' 'nonce-${nonce}' 'strict-dynamic' https://eu-assets.i.posthog.com`,
"connect-src 'self' https://eu.i.posthog.com",
"worker-src 'self' blob:",
].join("; ");
const page = `<!doctype html>
<script nonce="${nonce}">
document.addEventListener("securitypolicyviolation", (e) => console.log("blocked", e.violatedDirective, e.blockedURI));
</script>
<script type="module" nonce="${nonce}">
import posthog from "/module.js";
posthog.init("${TOKEN}", { api_host: "https://eu.i.posthog.com", defaults: "2026-08-30" });
setTimeout(() => console.log("recording:", posthog.sessionRecordingStarted()), 8000);
</script>`;
const sdk = readFileSync("node_modules/posthog-js/dist/module.js");
createServer((req, res) => {
if (req.url === "/module.js") {
res.writeHead(200, { "content-type": "text/javascript" });
return res.end(sdk);
}
const headers = { "content-type": "text/html" };
if (req.url !== "/nocsp") headers["content-security-policy"] = csp;
res.writeHead(200, headers);
res.end(page);
}).listen(4777);
With a project that has session replay on, the console shows this.
/ blocked connect-src https://eu-assets.i.posthog.com/array/phc_…/config
recording: false
/nocsp recording: true
With the wizard's policy surveys.js, posthog-recorder.js, dead-clicks-autocapture.js and web-vitals-with-attribution.js are never requested. Without the policy all of them load. Events and /flags/ go through in both cases.
The fix I would suggest is to add the assets host to connect-src as well, both in the guidance and in the review check. Also, with 'strict-dynamic' modern browsers ignore hosts in script-src, so adding the assets host there doesn't really change anything. The lazy-loaded scripts still load because a nonced script inserts them (that's why exception-autocapture.js loaded with the wizard's policy).
For now I worked around it by sending everything through a same-origin rewrite (/relay/* to eu.i.posthog.com and eu-assets.i.posthog.com) and keeping connect-src 'self'.
I ran it with wizard 3.0.0, Next.js 16.4.6 (Turbopack), posthog-js 1.454.2, EU Cloud, Chromium, macOS arm64 and Node 25.2.1.
- Lenguaje dominante
- TypeScript
- Estrellas
- 208
- Forks
- 58
- Merge medio
- 2 d 7 h
- PR fusionados (30 d)
- 76
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PostHog/wizard
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 2 días
-
wizard --version prints unknown when run through npxPosiblemente ocupada @bryanlundberg la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
PostHog/wizard#1460 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 2 días
-
Self-driving setup: checkbox labels and Confirm button overlap wrapped description textQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PostHog/wizard#986 · 4 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de PostHog/wizard
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
prio:low scope:world
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
OliverRomhagen/vrigstad-joyride#849 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
genfeedai/genfeed.ai#11916 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
erkamyaman/rust-anything#1153 ·
Los mantenedores suelen responder en 1 día
-
The Phase 5 report says 0.3.0 waits for the live checkPosiblemente ocupada @fzn0x la tomó hoy. Abiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día