項目是前后端分離:前端用vue開發,后端用的是springboot開發
會產生跨域問題,故在前端里用了代理
1.本前端項目是用vue開發:
1.1打包:終端 vscode快捷鍵:crtl+~ 然后npm run build
1.2:生成一個dist文件:復制到nginx下的html中。
1.3:更改nginx中 conf->nginx.conf
1.4.nginx -s quit強制停止,然后在start nginx.exe 進行啟動,有時nginx中重啟沒用,訪問 10.10.5.88:8085 就ok了。
記錄當把項目放在其他window系統下產生問題
1. listen 8085; 例如這樣子的,listen 和8085 中間最好是tab而不是空格,有時有問題,有時沒問題。
2.(問題)\dist/index.html" failed (123: The filename, directory name, or volume label syntax is incorrect), 當訪問的時候報500
該次解決:將 root D:\program\nginx-1.16.1\html\dist 換成 root D:/program/nginx-1.16.1/html/dist;
3.另一台電腦上配置:
server {
listen 8089;
server_name 192.16464.164.6;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root D:/program/nginx-1.16.1/html/dist;
try_files $uri $uri/ /index.html;
}
location /api { #4.當請求跨域時配置端口轉發
proxy_pass http://192.164648.1.646:8211/; #5.轉發地址
}
停止,再啟動,訪問。ok
如何打成jar包請看:https://www.cnblogs.com/yiyezhiqiuwuchen/p/12191113.html