混合内容,此请求已被阻止;内容必须通过HTTPS提供,Laravel

时间:2020-03-31 06:10:12

标签: laravel mixed-content laravel-7

我在生产环境中遇到此错误。仅在某些路线上,我认为有效路线与少数无效路线之间没有区别。我所有的路线都在web.php中,并且在前面,我尝试通过Vuejs / Axios访问。 另外,当我尝试访问它们时,两个URL都从错误中获取到https://,即使我尝试使用http://,也重定向到了https。

到目前为止我一直在尝试。

.env

APP_URL=https://my.url

web.php

URL::forceScheme('https');  //at the top of the file

App / Providers / AppServiceProvider

public function boot()
{
    URL::forceScheme('https');
}

也:

composer dump-autoload
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
php artisan config:cache
npm run prod

1 个答案:

答案 0 :(得分:0)

我找到了一个奇怪的解决方案。

我将路由名称从random_question更改为random,也将控制器方法名称从show更改为random,并且有效。