下一个路由未能在构建时创建子路由



要显示产品,我想对链接使用以下结构:

/collections/:slug/:id
到目前为止,我已经创建了这样的文件夹结构:
collections/
_category/
_id.vue
_slug.vue
index.vue

_slug。Vue和索引。

在本地运行一切正常,但当我让npm运行dist和push live时,试图访问:

/collections/_category or /collections/_category/_id

给出not found.

我应该做什么改变使它工作?

还有一件事要提的是,当从主页访问产品时,一切都很好,产品显示出来,但当我试图刷新该页面时,我得到404 notfound, nnix。这可能是一个linux问题吗?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;
}
}

在我让它工作之后,我甚至不知道它之前是如何工作的....

我的工作方式:

已提交并将项目中的所有文件推送到服务器。通过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

现在一切都很顺利。

最新更新