【发布时间】:2018-06-11 04:57:21
【问题描述】:
我正在尝试通过 Heroku 部署我的第一个 React 应用程序。它在本地环境中运行时完全正常,但是当我部署它时,它无法完成对 The Movie DB API 的请求,并出现以下错误:
The page at 'https://boiling-escarpment-83243.herokuapp.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.themoviedb.org/3/genre/list?api_key='. This content should also be served over HTTPS.
和
{"status_code":7,"status_message":"Invalid API key: You must be granted a valid key."}
同样,本地的 API 密钥没有问题。最初我使用的包中的 base_uri 指向一个 http URL,但我将其更新为 https(并测试了 https 路由,它似乎受支持:https://api.themoviedb.org/3/movie/550)。这是我的非工作应用程序:https://boiling-escarpment-83243.herokuapp.com/
【问题讨论】:
-
您是否为两个域都注册了应用程序?一些 API 使用特定领域的 API 密钥
-
@charlietfl 似乎您不需要为只读应用程序使用该 api 注册域,但也许我错了......
标签: javascript ajax reactjs heroku