要显示产品,我想使用此链接的结构:
/collections/:slug/:id到目前为止,我已经创建了这个文件夹结构:
collections/
_category/
_id.vue
_slug.vue
index.vue_slug.vue和index.vue在集合文件夹中。
在本地,一切运行正常,但当我让npm运行dist并推送生活时,当我试图访问:
/collections/_category or /collections/_category/_id它给出了未找到的。
我应该进行哪些更改才能使其正常工作?
还有一件事要提的是,当从主页访问产品时,一切正常,产品显示,但当我试图刷新页面时,我得到404NotFound,ngnix。会不会是ngnix的问题?Nginx配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/{link_to_the_project}/dist;
server_name {mydomainname}.ro;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
}
location ~ /\.ht {
deny all;
}
}发布于 2021-01-22 16:28:32
在我使它工作后,我甚至不知道它以前是如何工作的……
它对我起作用的方式是:
提交项目中的所有文件并将其推送到服务器。通过ssh连接到服务器并在服务器上运行:npm install
安装npm后,我将nginx配置修改为:
server {
listen 80;
server_name {mydomain}.ro;
location / {
proxy_pass http://127.0.0.1:3000;//run `npm run start` in project for ip
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;
}
}已安装的pm2:
npm install pm2 -g然后运行:
pm2 start npm -- start现在,一切都运行得很完美。
https://stackoverflow.com/questions/65833437
复制相似问题