我在 Ionic 上创建了一个 PWA,并在本地主机 8100 上对其进行了本地测试,并将生产版本上传到 Firebase 托管,并且它可以正常工作。 但我想做的是能够在 NodeJS 服务器上托管 PWA。这是可能的? 我还没有找到关于它的明确信息...
有任何关于它的想法或文档吗?
致以诚挚的问候。
最佳答案
你需要有VPS,然后你安装nodejs和PM2运行后台nodejs,安装nginx配置代理运行nodejs,你可以看到:How To Set Up a Node.js Application for Production on Ubuntu 16.04 , How To Set Up a Node.js Application for Production on CentOS 7
//install pm2
$ npm install pm2 -g
$ cd /var/www/app-nodejs
$ pm2 start app.js
//install nginx on CentOS 7
sudo yum install nginx -y
//if using ubuntu, you install nginx on Ubuntu
sudo apt-get install nginx -y
//config nginx on CentOS 7
sudo nano /etc/nginx/nginx.conf
//edit file nginx.conf
location / {
proxy_pass http://localhost:8080;
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;
}
//restart nginx on CentOS 7
sudo systemctl restart nginx
关于node.js - 在 NodeJS 中部署和托管 PWA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51470188/