-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: help wantedstatus: can not reproduceNot enough information to reproduceNot enough information to reproduce
Description
Bug report
Describe the bug
A clear and concise description of what the bug is.
Issue summary: Strapi is not picking up the PUBLIC_URL and /admin is calling back to a localhost:port URL.
I have a clean install of Strapi which I hope to access through a reverse proxied internet address and the browser is reporting errors trying to access localhost:port. I have defined a public url in server.js according to instructions here
/config/server/js
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: env("PUBLIC_URL", "https://mydomain.wtf")
});
my nginx config is simple:
# strapi cms
server {
listen 80;
server_name myserver.wtf;
location / {
proxy_pass http://0.0.0.0:1337;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
bowser console errors:
main.b227e163.js:2 Refused to connect to 'http://localhost:1337/admin/project-type' because it violates the following Content Security Policy directive: "connect-src 'self' https:".
(anonymous) @ main.b227e163.js:2
main.b227e163.js:2 Error: Network Error
at e.exports (main.b227e163.js:2)
at XMLHttpRequest.y.onerror (main.b227e163.js:2)
(anonymous) @ main.b227e163.js:2
main.b227e163.js:2 Refused to connect to 'http://localhost:1337/admin/init' because it violates the following Content Security Policy directive: "connect-src 'self' https:".
t.default @ main.b227e163.js:2
main.b227e163.js:2 Refused to connect to 'http://localhost:1337/admin/init' because it violates the document's Content Security Policy.
Steps to reproduce the behavior
- install strapi on a server
- configure nginx as above
- access admin for first time
- see console errors in the browser
Expected behavior
Strapi should replace "localhost:port" with PUBLIC_URL when calling back to the server
Screenshots
If applicable, add screenshots to help explain your problem.

Code snippets
If applicable, add code samples to help explain your problem.
System
- Node.js version: 16.13
- NPM version: 8.1.2
- Strapi version: 4
- Database: n/a
- Operating system: docker/alpine 3.14
Additional context
Add any other context about the problem here.
alirezakay and benhk2005
Metadata
Metadata
Assignees
Labels
issue: help wantedstatus: can not reproduceNot enough information to reproduceNot enough information to reproduce