The wizard's CSP change leaves the assets host out of connect-src, so session replay and surveys never start
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 57/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- next.js, typescript
- Ambito
- developer-experience, security
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 208
- Fork
- 58
- Merge medio
- 2g 7h
- PR unite (30g)
- 76
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PostHog/wizard
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
wizard --version prints unknown when run through npxForse già presa @bryanlundberg l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
PostHog/wizard#1460 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Self-driving setup: checkbox labels and Confirm button overlap wrapped description textForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PostHog/wizard#986 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di PostHog/wizard
Issue simili
-
bug Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
scottbenton/Iron-Link#541 ·
I maintainer di solito rispondono entro 1 giorno
-
hosts settings: the SSH address field and the separate User field are two ways to name one SSH userAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
prime-radiant-inc/evener#8161 ·
I maintainer di solito rispondono entro 1 giorno
-
Ignore Rules is not workingApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nicobailon/pi-subagents#3420 ·
I maintainer di solito rispondono entro 1 giorno
-
Edit content TabList: selected tab's icon/label are hidden by its own selection indicator - a11yAperta01 type: bug 99 tag: UX Accessibility
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni