基礎(chǔ)設(shè)施
前端服務(wù)器:配置了https,并且暴露在公網(wǎng),配置了域名
后端服務(wù)器:沒有配置https,與前端服務(wù)器在同一子網(wǎng)內(nèi)
報(bào)錯(cuò)復(fù)現(xiàn)
strict-origin-when-cross-origin
chunk-libs.c13a1b18.js:51 Mixed Content: The page at 'https://xxx.xxx.com/#/login?redirect=%2Fdashboard' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://xxx.xxx.com/api/user/login'. This request has been blocked; the content must be served over HTTPS.
問題原因
http、https混合使用導(dǎo)致;
網(wǎng)站用的是 https 要跳轉(zhuǎn)到 http 請(qǐng)求,被瀏覽器阻止了
解決方案1
后端也使用https文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-536811.html
解決方案2
在調(diào)用http服務(wù)的html頁(yè)面中的head頭部加入如下內(nèi)容即可文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-536811.html
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
到了這里,關(guān)于前后端分離,不在同一服務(wù)器上部署,報(bào)錯(cuò)“strict-origin-when-cross-origin”解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!