Member-only story

VUE3 deployment record

Beck Moulton
Feb 27, 2023

--

  1. Nginx configuration
location /public/cis {
alias /Users/zhangsan//dist;
try_files $uri $uri/ public/cis/index.html
proxy_set_header Connection "";
proxy_set_header Host $http_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_http_version 1.1;
index index.html index.htm;
}

In the above configuration, it is necessary to note that the address after the location needs to be written to the try_files.

2. Vue project to write env file, file content:

VITE_BASE_URL="/public/cis "

VITE_BASE_URL data needs to be the same as nginx configuration

3. Vue route configuration writing

history: createWebHistory(import.meta.env.VITE_BASE_URL),

--

--

Beck Moulton
Beck Moulton

Written by Beck Moulton

Focus on the back-end field, do actual combat technology sharing Buy me a Coffee if You Appreciate My Hard Work https://www.buymeacoffee.com/BeckMoulton

No responses yet