简体   繁体   English

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

[英]Mixed content issue- Content must be served as HTTPS || Lumen || Swagger API

Mixed Content: The page at ' https://api.xyz.com/api/documentation ' was loaded over HTTPS,混合内容:“ https://api.xyz.com/api/documentation ”页面已加载到 HTTPS 上,

but requested an insecure stylesheet ' http://api.xyz.com/swagger-ui-assets/swagger-ui.css?v=26ec363936a21921c9fec290e551e3eb '.但请求了不安全的样式表' http://api.xyz.com/swagger-ui-assets/swagger-ui.css?v=26ec363936a21921c9fec290e551e3eb '。

This request has been blocked;此请求已被阻止; the content must be served over HTTPS.内容必须通过 HTTPS 提供。

I know how to solve this problem in Laravel but unable to solve this in case of Lumen.我知道如何在 Laravel 中解决这个问题,但在流明的情况下无法解决。

Tried Solutions:尝试过的解决方案:

  1. Added below line in AppServiceProvider在 AppServiceProvider 中添加以下行

    URL::forceSchema('https');

Check the APP_URL in the.env file which is set to http://localhost检查APP_URL文件中设置为http://localhost的 APP_URL

Heroku uses https://appname.herokuapp.com since it's in production but lumen uses http://localhost for dev mode so I fixed it by running heroku config:set APP_URL=https://localhost Heroku uses https://appname.herokuapp.com since it's in production but lumen uses http://localhost for dev mode so I fixed it by running heroku config:set APP_URL=https://localhost

update boot() method in app/Providers/AppServiceProvider.php file as bellow更新app/Providers/AppServiceProvider.php文件中的boot()方法如下

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

alse update APP_ENV to APP_ENV=prod in .evn file还将.evn文件中的 APP_ENV 更新为APP_ENV=prod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM