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.
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');
}*/
}
Most helpful comment
Use:
URL::forceScheme('https')
(Scheme not Schema)