【发布时间】:2018-05-06 00:10:05
【问题描述】:
我使用 api 调用创建了一个 Angular 应用程序。我已经将它部署在 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
【问题讨论】:
-
将
https://api.themoviedb.org/3/search/movie/粘贴到浏览器地址栏中,注意会发生什么:它重定向到相应的非https URL -
有什么解决办法吗?或者是 API 乱七八糟
标签: javascript angular api typescript https