I have default Digital Ocean installation of strapi. I've changed api based hostname for my domain and I have this error:
this:main.f910bea6.chunk.js:13 Mixed Content: The page at 'https://api.myhostname.app/admin' was loaded over HTTPS, but requested an insecure resource 'http://999.999.999.999/admin/init'. This request has been blocked; the content must be served over HTTPS.
Main site is displaying correctly. Problem is in admin panel.
This is my nginx config:
server {
# Listen HTTP
listen 443 ssl http2;
listen [::]:443 ssl http2;
#listen 80;
server_name api.myhostname.app;
ssl_certificate /etc/ssl/hostname.pem;
ssl_certificate_key /etc/ssl/hostname.key;
# Proxy Config
location / {
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
}
and .env file:
NGINX_URL=https://api.myhostname.app
ADMIN_JWT_SECRET="best"
and config:
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: env('NGINX_URL', ''),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
},
});
What's wrong?
I resolved the problem. This required rebuilding admin panel, like that:
npm run build
Weird but works.