亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

vue.js - Regarding the Vue-cli project, after deploying the request page app.js with Nginx in the VPS, it prompts a 404 error.
迷茫
迷茫 2017-05-16 17:07:03
0
3
723

I want to deploy my resume on my personal blog website.
I want to add a /me subpath after the server's domain name to access my resume.
Of course my resume is written in Vue and built with vue-cli
After deploying to the server, npm run dev and successfully running on the server port

But the browser request appears this

There is no app.js file at all

But if you run this vue-cli project locally

There is app.js here, so there is no problem

I have now eliminated the nginx problem. Now it’s time to build and deploy vue-cli. Why does this happen?

Is the code used when running the server different from that running locally?

General deployment is statically deployed using dist files. Isn’t it possible for vue-cli to deploy nginx reverse proxy to the server?

迷茫
迷茫

業(yè)精于勤,荒于嬉;行成于思,毀于隨。

reply all(3)
給我你的懷抱

Actually, I solved this problem myself. Do not deploy the project in a non-root directory on nginx, as the path can easily be wrong. If a server has multiple projects, you can configure servers with different ports on nginx or directly create a second-level domain name to point to nginx.

伊謝爾倫

1. Find configindex.js;
2、將build中的assetsPublicPath:'/'改為assetsPublicPath:'';
3、重新執(zhí)行打包:npm run build in the project;
4. Publish and try again.

世界只因有你

For projects built with vue-cli, use the npm run dev 啟動(dòng)服務(wù)適用于開發(fā)模式,相當(dāng)于啟動(dòng)了一個(gè)server。
線上部署很少采用這種形式,線上部署都會(huì)提前npm run build,將代碼打包到dist directory, and the dist directory is actually a runnable index.html+static file. When we deploy, we only need to throw the dist directory to the server instead of starting a server.
nginx configuration is also relatively simple:

server{
    listen 80;
    server_name domain.com;
    location /vue {
        alias /var/www/dist; #dist目錄在服務(wù)器的位置
    }
}

In this way, when accessing https://域名/vue, the dist directory will be located, and the dist directory is the static file that can be run after our project is built.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template