問題第一次部署前端,將vue生成的dist 文件部署到nginx后,進(jìn)入頁面后post請求查詢數(shù)據(jù)時,出現(xiàn)405 not allowed,經(jīng)查閱發(fā)現(xiàn),nginx 靜態(tài)資源訪問不支持post請求。文章來源:http://www.zghlxwxcb.cn/news/detail-506447.html
解決方案文章來源地址http://www.zghlxwxcb.cn/news/detail-506447.html
location / {
root /usr/local/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
error_page 405 =200 @405; #405頁面處理
}
#加入下面代碼
location @405 {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#ip為后端服務(wù)地址
proxy_pass http://192.168.3.129:8081$request_uri ;
}
到了這里,關(guān)于解決nginx 部署前端post請求405 not allowed的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!