Lumen-framework: \URL::forceSchema('https'); is not compatible with the Lumen 5.5 version

Created on 2 Mar 2018  路  5Comments  路  Source: laravel/lumen-framework

  • Lumen Version: 5.5.2
  • PHP Version:7.0
  • Database Driver & Version:

Description:

On the production server, I want to use the "https" scheme forcefully but without any additional middleware and the mod_rewrite.

Lumen older version I was using the approach

app/providers/appServiceProvider.php in boot method

use IlluminateSupportFacadesURL;
URL::forceSchema('https');

Is there any solution for that.

Most helpful comment

Use:

URL::forceScheme('https')

(Scheme not Schema)

All 5 comments

Use:

URL::forceScheme('https')

(Scheme not Schema)

Heya, URL::forceScheme('https') works for me in the latest Lumen release. Did you make sure that the AppServiceProvider was registered? Did you enable facades?

use IlluminateSupportServiceProvider;

use LaravelLumenRoutingUrlGenerator;
class AppServiceProvider extends ServiceProvider
{

public function boot(UrlGenerator $url){

     if(env('REDIRECT_HTTPS'))
      {
        $url->forceSchema('https');
      }


}

$app->register(AppProvidersAppServiceProvider::class);
enable in boostrap/app.php

if use Cloudflare web service to redirect http to https
please comment in boot function codes

AppServiceProvider.php file in laravel
update to this boot function
public function boot(UrlGenerator $url) { /* if(env('REDIRECT_HTTPS')) { $url->forceSchema('https'); }*/ }

Was this page helpful?
0 / 5 - 0 ratings