【发布时间】:2021-05-08 23:43:18
【问题描述】:
我正在通过使用 reactjs 构建一个小型电影搜索应用来练习 fetch-api。
它在 localhost 上运行良好,但是当我在 netlify 上部署它时出现此错误。
混合内容:“https://movie-search-abhi28069.herokuapp.com/”的页面是通过 HTTPS 加载的,但请求了不安全的资源“http://api.themoviedb.org/3/search/”电影?api_key=####&query=prime'。此请求已被阻止;内容必须通过 HTTPS 提供。
fetch(
"https://api.themoviedb.org/3/search/movie/?api_key=####&query=" +
term
)
.then((res) => res.json())
.then((data) => setMovies(data.results))
.catch((err) => console.log(err));
当组件被加载以获取热门电影时,我还有另一个 fetch 调用,它工作正常。不知道为什么我的搜索请求会自动转换为 http。
【问题讨论】:
标签: reactjs fetch-api mixed-content themoviedb-api