【问题标题】:Heroku error : This request has been blocked; the content must be served overHeroku 错误:此请求已被阻止;内容必须在
【发布时间】:2021-09-11 13:23:18
【问题描述】:

我已将我的 laravel 应用程序部署到 heroku。我在下面有这个文件作为我的 frontend.blade.php 但不知何故 heroku 把这个错误消息扔给了 chrome 开发者控制台。

错误:

geeksolution.herokuapp.com/:18 混合内容:“https://geeksolution.herokuapp.com/”页面通过 HTTPS 加载,但请求的样式表不安全“http://geeksolution.herokuapp.com/”前端/css/main.css'。此请求已被阻止;内容必须通过 HTTPS 提供。 geeksolution.herokuapp.com/:22 混合内容:“https://geeksolution.herokuapp.com/”页面通过 HTTPS 加载,但请求了不安全的样式表“http://geeksolution.herokuapp.com/frontend/css” /app.minify.css'。此请求已被阻止;内容必须通过 HTTPS 提供。 geeksolution.herokuapp.com/:1 混合内容:“https://geeksolution.herokuapp.com/”的页面是通过 HTTPS 加载的,但请求的脚本不安全“http://geeksolution.herokuapp.com/frontend/js /app.js'。此请求已被阻止;内容必须通过 HTTPS 提供。 geeksolution.herokuapp.com/:1 混合内容:“https://geeksolution.herokuapp.com/”的页面是通过 HTTPS 加载的,但请求的网站图标不安全“http://geeksolution.herokuapp.com/frontend/images /content/favicon.png'。此请求已被阻止;内容必须通过 HTTPS 提供。 site.webmanifest:1 加载资源失败:服务器响应状态为 404(未找到) site.webmanifest:1 清单:行:1,列:1,语法错误。 geeksolution.herokuapp.com/:1 混合内容:“https://geeksolution.herokuapp.com/”页面通过 HTTPS 加载,但请求的样式表不安全“http://geeksolution.herokuapp.com/frontend/css /main.css'。此请求已被阻止;内容必须通过 HTTPS 提供。 geeksolution.herokuapp.com/:1 混合内容:“https://geeksolution.herokuapp.com/”页面通过 HTTPS 加载,但请求的样式表不安全“http://geeksolution.herokuapp.com/frontend/css /app.minify.css'。此请求已被阻止;内容必须通过 HTTPS 提供。 DevTools 无法加载源地图:无法加载 chrome-extension://fheoggkfdfchfphceeifdbepaooicaho/sourceMap/chrome/iframe_handler.map 的内容:HTTP 错误:状态代码 404,net::ERR_UNKNOWN_URL_SCHEME DevTools 无法加载源地图:无法加载 chrome-extension://fheoggkfdfchfphceeifdbepaooicaho/sourceMap/chrome/content.map 的内容:HTTP 错误:状态代码 404,net::ERR_UNKNOWN_URL_SCHEME site.webmanifest:1 加载资源失败:服务器响应状态为 404(未找到)

前端.blade.php:

    <meta charset="utf-8" />
    <title>Geek Solution</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <meta property="og:title" content="" />
    <meta property="og:type" content="" />
    <meta property="og:url" content="" />
    <meta property="og:image" content="" />

    <link rel="manifest" href="site.webmanifest" />
    <link rel="apple-touch-icon" href="{{ url('/frontend/images/content/favicon.png') }}" />
    <!-- Place favicon.ico in the root directory -->

    <link rel="stylesheet" href="{{ url('/frontend/css/main.css') }}" />
    <link rel="icon" href="{{ url('/frontend/images/content/favicon.png') }}" />

    <meta name="theme-color" content="#000" />
  <link rel="icon" href="favicon.ico"><link href="{{ url('/frontend/css/app.minify.css') }}" rel="stylesheet"></head>


【问题讨论】:

  • 将您的样式表链接替换为安全版本(https 而不是 http) 您无法在所有现代浏览器的 https 页面中加载 http 资源。在 config 或 .env 中更改您的应用程序基本 url

标签: php html css laravel heroku


【解决方案1】:

这将是由于服务器配置错误导致 laravel 无法知道您的应用在 https 上运行。

请参阅Laravel generate secure https URL from route,了解如何强制生成安全链接。

任何你使用url方法的地方都应该改成secure_url辅助方法https://laravel.com/docs/8.x/helpers#method-secure-url

【讨论】:

  • 你不必使用secure_url(),如果请求和你配置的基本url在https中,url()方法将使用https。在你的项目中使用secure_url() 有一个缺点,在没有设置适当的服务器的情况下在本地环境中维护代码可能会非常痛苦
猜你喜欢
  • 2021-08-29
  • 2015-03-23
  • 1970-01-01
  • 1970-01-01
  • 2018-12-18
  • 2020-12-19
  • 2016-03-01
  • 2016-08-28
  • 2022-01-11
相关资源
最近更新 更多