一、本地服務器部署:
解決頁面刷新404問題:
1、使用 hash
模式
2、當路徑不匹配的時候,直接訪問 index.html
3、使用插件:connect-history-api-fallback
https://www.npmjs.com/package/connect-history-api-fallback
npm install --save connect-history-api-fallback
解決請求地址的代理問題:
https://www.npmjs.com/package/http-proxy-middleware
二、本地 nginx
服務器部署:
更改
nginx.conf
文件:
三、云服務器部署:
1、買一個云服務器,自己玩就用輕量級服務器
2、下載xShell
:寫命令
https://www.xshell.com/zh/free-for-home-school/
連接服務器
3、下載 xftp
:傳文件
https://www.xshell.com/zh/xftp/
在 var
目錄下新建一個項目文件夾,將 dist
中的所有文件放在新的文件夾中
4、在xShell
的服務器中,安裝nginx
:
yum install nginx
然后在etc
中找到nginx
文件夾,表示安裝成功
5、更改nginx
配置:
6、在xShell
的服務器中,運行服務器:
service nginx start