Skip to content

Commit fc11f25

Browse files
committed
Add FORCE_HTTPS configuration to environment and update AppServiceProvider
1 parent f980e48 commit fc11f25

File tree

5 files changed

+9
-2
lines changed

5 files changed

+9
-2
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
55
APP_URL=http://localhost
6+
FORCE_HTTPS=false
67

78
APP_LOCALE=en
89
APP_FALLBACK_LOCALE=en

app/Providers/AppServiceProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Providers;
44

5+
use Illuminate\Routing\UrlGenerator;
56
use Illuminate\Support\ServiceProvider;
67

78
class AppServiceProvider extends ServiceProvider
@@ -17,8 +18,10 @@ public function register(): void
1718
/**
1819
* Bootstrap any application services.
1920
*/
20-
public function boot(): void
21+
public function boot(UrlGenerator $url): void
2122
{
22-
//
23+
if (config('app.force_https')) {
24+
$url->forceScheme('https');
25+
}
2326
}
2427
}

config/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
'name' => env('APP_NAME', 'Laravel'),
17+
'force_https' => env('FORCE_HTTPS', false),
1718

1819
/*
1920
|--------------------------------------------------------------------------

docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ services:
4141
- APP_ENV=local
4242
- APP_DEBUG=true
4343
- APP_URL=http://localhost:8080
44+
- FORCE_HTTPS=false
4445

4546
# Database
4647
- DB_CONNECTION=mysql

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
- APP_ENV=production
2323
- APP_DEBUG=false
2424
- APP_URL=http://localhost:8080
25+
- FORCE_HTTPS=true
2526

2627
# Database (example with MySQL)
2728
- DB_CONNECTION=mysql

0 commit comments

Comments
 (0)