混合内容问题-内容必须用作HTTPS ||流明|| Swagger API

时间:2019-09-23 06:39:04

标签: laravel laravel-5 lumen lumen-5.2

混合内容:“ https://api.xyz.com/api/documentation”页面是通过HTTPS加载的,

,但请求了不安全的样式表“ http://api.xyz.com/swagger-ui-assets/swagger-ui.css?v=26ec363936a21921c9fec290e551e3eb”。

此请求已被阻止;内容必须通过HTTPS提供。

我知道如何在Laravel中解决此问题,但在流明的情况下无法解决。

尝试的解决方案:

  1. 在AppServiceProvider中添加以下行

    URL::forceSchema('https');  
    

2 个答案:

答案 0 :(得分:0)

检查 .env 文件中设置为 APP_URLhttp://localhost

Heroku 使用 https://appname.herokuapp.com,因为它正在生产中,但 lumen 使用 http://localhost 作为开发模式,所以我通过运行 heroku config:set APP_URL=https://localhost 来修复它

答案 1 :(得分:0)

更新 boot() 文件中的 app/Providers/AppServiceProvider.php 方法如下

public function boot()
{
    if(env('APP_ENV') !== 'local') {
       URL::forceScheme('https');
    }
}

同时将 APP_ENV=prod 文件中的 APP_ENV 更新为 .evn