混合内容(laravel) [英] Mixed Content (laravel)

查看:44
本文介绍了混合内容(laravel)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在每个页面上收到以下错误

I get the following error (on every page)

app.js:703混合的内容:" https://sitename.com/"上的页面已加载通过 HTTPS,但请求了一个不安全的 XMLHttpRequest 端点 'http://sitename.com/index.php/getMessages.此内容也应通过HTTPS提供.

app.js:703 Mixed Content: The page at 'https://sitename.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://sitename.com/index.php/getMessages'. This content should also be served over HTTPS.

该站点由Laravel构建.有谁知道如何解决此错误?

The site is build with Laravel. Is there anybody who knows how to fix this error?

推荐答案

在我的情况下,这是因为我不知道 asset()函数不能自动处理https(如所指出的那样)通过法兰克福-拉拉维尔的答案).

In my case it's because I wasn't aware that the asset() function didn't handle https automatically (as pointed out by frankfurt-laravel's answer).

要解决此问题,由于我没有在开发人员中使用SSL,因此将.env中的 ASSET_URL 设置为https url:

To get around this, since I don't use SSL in dev, I set ASSET_URL in the .env to the https url:

APP_URL=https://example.com
ASSET_URL="${APP_URL}"

这将覆盖 asset()函数以使用https url,而无需完全修改该函数.有关更多上下文,请参阅文档.

This overrides the asset() function to use the https url, without having to modify the function at all. See the docs for more context.

这篇关于混合内容(laravel)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆