1.我們的前端代碼,通過npm 打包,dist文件就是前端打包好的文件
2.本地部署Nginx服務
https://blog.csdn.net/bestxianfeng163/article/details/84553166
3.配置,將Nginx服務與前端代碼相關聯
本地設置的代理是這樣的,本地測試的通過node.js
在Nginx上的配置如下(注意在ng服務器的文件指向,這時候發出去的請求全部由Ng代理,我們配置文件中配地址就失效了,別忘了配置轉發代理地址)
upstream loanBalance{
server 127.0.0.1:8085;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root D:\TYProject\ic-web\dist;
index index.html index.htm;
}
location /api{
proxy_pass http://loanBalance/;
}
}