"Refused to connect to http://localhost:1337/admin/init" after deploying Strapi
Blog post from Strapi
A blank Strapi admin screen after deployment, accompanied by a CSP error involving `localhost:1337`, usually results from an admin React bundle built without the correct public URL rather than from an actual CSP configuration problem. Because Strapi embeds its API URL during `strapi build`, deployments must provide `PUBLIC_URL` at build time, set `config/server` to use the public HTTPS address, and rebuild the admin panel before starting production. The server should bind to `0.0.0.0` inside containers, read its internal listening port from `PORT`, and distinguish that port from the externally visible URL, which commonly uses HTTPS without an explicit port. Deployments should also ensure a fresh production build is included in the release artifact, configure a separate admin URL when applicable, and enable `proxy.koa` when operating behind a reverse proxy. CSP rules should only be expanded when the admin legitimately connects to external services such as S3 or Cloudinary, since allowing localhost merely hides the symptom while leaving the incorrectly compiled API endpoint unresolved.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.