Error: Mixed Content, While Deploying React app on Github
Error: Mixed Content, While Deploying React app on Github
我 运行 在 GitHub 页面上部署 React 应用程序时遇到了一个小问题。该应用程序在实时服务器上运行良好。但是,当我将代码推送到 gitHub 并进行测试时。发生此错误:
Mixed Content: the page at '<domain>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoing 'http://www.omdbapi.com/...' ...
我知道这与我使用的api有关。它是 omdb api and uses HTTP protocol for a get request. I tried changing the HTTP to https and though it works on the live server. It does not on the Github page,给我和以前一样的错误。
代码:
const apirul = 'http://www.omdbapi.com/?apikey=...';
// ...
Axios(apiurl + "&=s="+state.s)
.then(data => {
console.log(data);
let results = data.Search;
setState(prevState => {
return { ...prevState, results }
})
})
.catch(e => {
console.log(e)
})
// ...
正在查看 GitHub Pages and the source it's got, I suspect your push to GitHub failed as the code in the repo is still pointing to http://www.omdbapi.com/?apikey=ad5bdfd0
(and was last updated 17 hours ago). I took a screenshot to to confirm。
将 URL 更改为 https://
应该可以修复它,尽管您 可以 使用相对 url 的协议(即 //
) 如果必须的话。
我 运行 在 GitHub 页面上部署 React 应用程序时遇到了一个小问题。该应用程序在实时服务器上运行良好。但是,当我将代码推送到 gitHub 并进行测试时。发生此错误:
Mixed Content: the page at '<domain>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoing 'http://www.omdbapi.com/...' ...
我知道这与我使用的api有关。它是 omdb api and uses HTTP protocol for a get request. I tried changing the HTTP to https and though it works on the live server. It does not on the Github page,给我和以前一样的错误。
代码:
const apirul = 'http://www.omdbapi.com/?apikey=...';
// ...
Axios(apiurl + "&=s="+state.s)
.then(data => {
console.log(data);
let results = data.Search;
setState(prevState => {
return { ...prevState, results }
})
})
.catch(e => {
console.log(e)
})
// ...
正在查看 GitHub Pages and the source it's got, I suspect your push to GitHub failed as the code in the repo is still pointing to http://www.omdbapi.com/?apikey=ad5bdfd0
(and was last updated 17 hours ago). I took a screenshot to to confirm。
将 URL 更改为 https://
应该可以修复它,尽管您 可以 使用相对 url 的协议(即 //
) 如果必须的话。