我构建一个 React 项目只是为了尝试一些东西,我在使用时遇到问题SWAPI(星球大战 API) https://swapi.dev/.
我不断收到Mixed Content Error
当我尝试在我的 React 项目中通过 axios 使用他们的 API 时。
Mixed Content: The page at 'https://zlerp.github.io/react-StarWars/#/people/2' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://swapi.dev/api/people/3/'. This request has been blocked; the content must be served over HTTPS.
即使我用硬编码 URLhttps://swapi.dev/api/people/3/
,我仍然收到混合内容错误。
非常感谢任何和所有的帮助。
您可以在这里看到错误:https://zlerp.github.io/react-StarWars/#/people/3 https://zlerp.github.io/react-StarWars/#/people/3
React 组件发出请求
I am just using Axios and the hardcoded URL with https
.
请求标头
The response Location is showing http
could that be something to do with the issue? if so how can I change this?
调用栈
The Call Stack shows that it is going through the Person.js
file shown in the first image and you can see the line numbers there.
这与以下事实有关:API 是通过 http 提供的,而您的网站是通过 https 加载的,因此浏览器会阻止该请求。
由于您无法控制第 3 方 api,因此您可以通过添加元标记来解决问题<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)