After spending many hours on this issue I’m giving up.
It appears that it is now not possible to run strapi in develop mode on a domain with https, because of the new VITE requirement.
I wanted to have an instance of strapi always running in development mode at a specific domain path.
This configuration will not work an gives the error above. The only way to get it working is through doing run develop on the command line and access strapi through the IP address.
http://x.x.x.x:1337
module.exports = {
apps: [{
name: 'devStrapi',
url: 'https://dev.strapi.com',
cwd: '/mnt/volume/www/cms',
script: 'npm',
args: 'run develop',
env: {
NODE_ENV: 'development',
HOST: '127.0.0.1',
PORT: 1337,
DATABASE_HOST: 'x',
DATABASE_PORT: '3306',
DATABASE_NAME: 'DB',
DATABASE_USERNAME: 'user',
DATABASE_PASSWORD: 'pass',
DOMAIN_URL: 'https://dev.strapi.com'
}
Nginx config:
upstream devStrapi {
server 127.0.0.1:1337; # Matches ecosystem.config.js
keepalive 64;
}
server {
listen 443 ssl;
server_name https://dev.strapi.com;
access_log /var/log/nginx/dev.strapi.com-access.log;
error_log /var/log/nginx/dev.strapi.com-error.log;
ssl_certificate /etc/letsencrypt/live/dev.strapi.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dev.strapi.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# Forward everything to Strapi
location / {
proxy_pass http://devStrapi;
proxy_set_header Host $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 Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}
}
server {
# Redirect HTTP to HTTPS
if ($host = dev.strapi.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name dev.strapi.com;
listen 80;
return 404; # managed by Certbot
}
}
]
};