javascript - API 请求被阻止,内容必须通过 HTTPS 提供
问题描述
我使用 api 调用创建了一个角度应用程序。我已经将它部署在 github 页面中。然后,当每次 api 调用时,我都会收到此错误消息。
getList(input) {
const url = '/api.themoviedb.org/3/search/movie/?api_key=b6dba21fefcead3510c8ddf58eb57d43&query=' + input;
return this.httpClient.get<RootResult>(url);
}
我在开发工具控制台中收到此错误:
Mixed Content: The page at 'https://githamza.github.io/ngxs-app-example/home' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.themoviedb.org/3/search/movie?api_key=b6dba21fefcead3510c8ddf58eb57d43&query=l'. This request has been blocked; the content must be served over HTTPS.
我在我的 api 中使用相对路径,但它总是添加http
而不是https
这是我的 github 页面示例:https ://githamza.github.io/ngxs-app-example
解决方案
您的 API 在 http 后面,因此您不能从 https(客户端)应用程序调用 http api,这违反了 https 安全策略.. 应用程序和 api 都应该使用相同的协议
更新:将网址更改为如下
const url = 'https://api.themoviedb.org/3/search/movie/?api_key=b6dba21fefcead3510c8ddf58eb57d43&query=' + input;
推荐阅读
- android - Android 导航抽屉在顶部添加了一个带有较暗阴影的空白空间
- php - Laravel 图像干预避免旋转
- utf-8 - Microsoft Outlook 未显示德语变音符号
- amazon-web-services - EC2 公共 DNS 显示 404 没有 https
- java - Spring boot Rest 以空主体响应我的 @ControllerAdvice 中覆盖的异常以外的异常
- arrays - 来自 Yaml 的数组 - Golang
- sql - 我可以在 SQL 中制作交互式过滤器吗?
- c - GCC:为 POSIX 函数获取警告隐式函数声明,但该函数已声明
- java - javax验证约束在Spring Boot中不起作用
- html - 无法加粗表中的第一列。我已经尝试了正常的方法