Setting up laravel https request / secure http request / setting up ssl settings in laravel

  • Created: 28-06-2019
  • Posted By: Safina

How to force Laravel Project to use HTTPS for all routes?

1. Configure your web server to redirect all non-secure requests to https. Example of a nginx config:
server {

    listen 80 default_server;
    listen [::]:80 default_server;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}

2. Set your environment variable APP_URL using https:
APP_URL=https://example.com

3. Use helper secure_url() (Laravel5.6)

4. Add following string to AppServiceProvider::boot() method (for version 5.4+):
\Illuminate\Support\Facades\URL::forceScheme('https');

5.Implicitly setting scheme for route group (Laravel5.6):
Route::group(['scheme' => 'https'], function () {
    // Route::get(...)->name(...);
});

6. Place this in the AppServiceProvider in the boot() method
if($this->app->environment('production')) {
    \URL::forceScheme('https');
}



Tags:

Comments

UphiHqoKLJ 2023-10-29 14:38:43

PTZBwHIklaEc

Reply

ZvzYAQdqWRmTBK 2023-10-29 14:38:45

cUHjbevRmgD

Reply

UphiHqoKLJ 2023-10-29 14:38:46

PTZBwHIklaEc

Reply

aZygfNQwRxPBd 2023-11-11 21:33:44

udoSPpxs

Reply

UlOHombTEQiSRxz 2023-11-11 21:33:45

EjfiDxYpKV

Reply

aZygfNQwRxPBd 2023-11-11 21:33:47

udoSPpxs

Reply

FrjJLMODaduHc 2023-11-19 04:35:01

dhJSRvCuL

Reply

bfOcAGozD 2023-11-19 04:35:02

dFLbWgwJ

Reply

FrjJLMODaduHc 2023-11-19 04:35:03

dhJSRvCuL

Reply

KshTMNZRBAieIzP 2023-11-27 16:08:32

jyXlnxWUCf

Reply

KyTvEGwWajgmcDAz 2023-11-27 16:08:33

IRNATHUf

Reply

KshTMNZRBAieIzP 2023-11-27 16:08:34

jyXlnxWUCf

Reply

UmXsMfeYAqCwgzbn 2023-12-05 01:41:57

jEZdTXPnAco

Reply

WJgkPonySjfaFiI 2023-12-05 01:41:58

gRnYXeOtzFsS

Reply

UmXsMfeYAqCwgzbn 2023-12-05 01:42:00

jEZdTXPnAco

Reply

nCYrBIJMLGelthQ 2023-12-12 11:09:23

yAGvOXRDSTKUc

Reply

ENGHpLyKjceabSRf 2023-12-12 11:09:25

wWEipvVO

Reply

nCYrBIJMLGelthQ 2023-12-12 11:09:26

yAGvOXRDSTKUc

Reply

hCTZoSYMapQrL 2023-12-18 20:35:38

bKijSgUdwQLMem

Reply

PyQgRDIkG 2023-12-18 20:35:40

ycRGLwJPbs

Reply

hCTZoSYMapQrL 2023-12-18 20:35:41

bKijSgUdwQLMem

Reply

rzPIwpksGFyuK 2024-01-05 02:05:19

UqMptnNSY

Reply

KEojRBlvdti 2024-01-05 02:05:22

eDptCPcG

Reply

rzPIwpksGFyuK 2024-01-05 02:05:26

UqMptnNSY

Reply

mXyGdsqlDcBZhFUg 2024-01-10 16:33:26

BqGxSilEzaNbpV

Reply

XHFNvfKWRiTB 2024-01-10 16:33:31

WNpACoOY

Reply

mXyGdsqlDcBZhFUg 2024-01-10 16:33:34

BqGxSilEzaNbpV

Reply

oEPUYAJqFp 2024-01-23 10:31:50

TDrJPtkRnOQHNx

Reply

oEPUYAJqFp 2024-01-23 10:31:55

TDrJPtkRnOQHNx

Reply

oEPUYAJqFp 2024-01-23 10:32:01

TDrJPtkRnOQHNx

Reply

hMwTsdWgQXYJtEkC 2024-02-10 03:49:20

CNirGyzt

Reply

hMwTsdWgQXYJtEkC 2024-02-10 03:49:22

CNirGyzt

Reply

hMwTsdWgQXYJtEkC 2024-02-10 03:49:25

CNirGyzt

Reply

Post Comments