发出此请求时出现混合内容错误(即使它是 https)

Getting mixed content error while making this request (even though it is https)

我正在通过使用 reactjs.

构建一个小型电影搜索应用来练习 fetch-api

它在 localhost 上工作正常,但是当我将它部署在 netlify 上时出现此错误。

Mixed Content: The page at 'https://movie-search-abhi28069.herokuapp.com/' was loaded over HTTPS, but requested an insecure resource 'http://api.themoviedb.org/3/search/movie?api_key=####&query=prime'. This request has been blocked; the content must be served over 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));

加载组件以获取 热门电影 时,我有另一个获取调用,它工作正常。不确定为什么我的搜索请求会自动转换为 http

根据https://www.themoviedb.org/talk/5dd34e7957d3780015dcfd99
使用尾部斜杠,您的请求将被重定向到 http.
删除结尾的斜杠将解决问题。

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));