当我在 GCP/Heroku/Netlify 上托管应用程序时,未在 react.js 应用程序中获取数据
Data is not being fetched in react.js app when I host it on GCP/Heroku/Netlify
我正在尝试从 OMDB 按标题获取一些电影数据。它在我的机器上运行良好,但是当我将它托管在 GCP/Heroku/Netlify 等提供商时,我的搜索不会 return 任何东西。这是 GCP 托管站点的 link:https://joypaultheshoppies1234.web.app and here is the repo with codes: https://github.com/cosmicRover/the_shoppies 您可以在 gif 中看到搜索应该 return 一些项目 JSON
失败并显示错误消息:
Mixed Content: The page at 'https://joypaultheshoppies1234.web.app/' was loaded
over HTTPS, but requested an insecure resource 'http://www.omdbapi.com/?s=T&apikey=[your_api_key]'.
This request has been blocked; the content must be served over HTTPS.
您的浏览器正在阻止从 https://joypaultheshoppies1234.web.app/ 获取数据,因为您正在从安全站点 (https
) 向非安全端点 (http
) 发出请求。它 不是 在您的本地计算机上失败,因为(我假设)您的本地 运行 站点不安全。
解法:
将应用程序中的 URL(协议)字符串更改为从 http
到 https
的端点。 (https
受该 OMDB 端点支持。)
例如:https://www.omdbapi.com/?s=Top+Gun&apikey=[your_api_key]
Mixed content
When a user visits a page served over HTTPS, their
connection with the web server is encrypted with TLS and is therefore
safeguarded from most sniffers and man-in-the-middle attacks. An HTTPS
page that includes content fetched using cleartext HTTP is called a
mixed content page. Pages like this are only partially encrypted,
leaving the unencrypted content accessible to sniffers and
man-in-the-middle attackers. That leaves the pages unsafe.
我正在尝试从 OMDB 按标题获取一些电影数据。它在我的机器上运行良好,但是当我将它托管在 GCP/Heroku/Netlify 等提供商时,我的搜索不会 return 任何东西。这是 GCP 托管站点的 link:https://joypaultheshoppies1234.web.app and here is the repo with codes: https://github.com/cosmicRover/the_shoppies 您可以在 gif 中看到搜索应该 return 一些项目 JSON
失败并显示错误消息:
Mixed Content: The page at 'https://joypaultheshoppies1234.web.app/' was loaded
over HTTPS, but requested an insecure resource 'http://www.omdbapi.com/?s=T&apikey=[your_api_key]'.
This request has been blocked; the content must be served over HTTPS.
您的浏览器正在阻止从 https://joypaultheshoppies1234.web.app/ 获取数据,因为您正在从安全站点 (https
) 向非安全端点 (http
) 发出请求。它 不是 在您的本地计算机上失败,因为(我假设)您的本地 运行 站点不安全。
解法:
将应用程序中的 URL(协议)字符串更改为从 http
到 https
的端点。 (https
受该 OMDB 端点支持。)
例如:https://www.omdbapi.com/?s=Top+Gun&apikey=[your_api_key]
Mixed content
When a user visits a page served over HTTPS, their connection with the web server is encrypted with TLS and is therefore safeguarded from most sniffers and man-in-the-middle attacks. An HTTPS page that includes content fetched using cleartext HTTP is called a mixed content page. Pages like this are only partially encrypted, leaving the unencrypted content accessible to sniffers and man-in-the-middle attackers. That leaves the pages unsafe.