Skip to content

Commit afd4a33

Browse files
authored
Merge pull request #470 from dbarzin/dev
add force_https environment variable
2 parents c763824 + 5c3fc9f commit afd4a33

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.env.ci

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
APP_NAME=Laravel
2-
APP_ENV=local
2+
APP_ENV=production
33
APP_KEY=
4+
APP_FORCE_HTTPS=false
45
APP_DEBUG=true
56
APP_URL=http://localhost
67

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
APP_NAME=Deming
2-
APP_ENV=local
2+
APP_ENV=production
33
APP_KEY=
4+
APP_FORCE_HTTPS=false
45
APP_DEBUG=true
56
APP_URL=http://deming.yourdomain.com
67
APP_TIMEZONE='Europe/Paris'

app/Providers/AppServiceProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ public function register()
2828
*/
2929
public function boot()
3030
{
31-
if (App::environment('production')) {
31+
if (
32+
(App::environment('production') && (config('app.force_https')===null))
33+
||
34+
Config::get('app.force_https')
35+
)
36+
{
3237
URL::forceScheme('https');
3338
}
3439

35-
if (env('APP_DEBUG')) {
40+
if (config('app.debug')) {
3641
DB::listen(function ($query) {
3742
Log::info(
3843
$query->sql,

config/app.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828

2929
'env' => env('APP_ENV', 'production'),
3030

31+
/*
32+
|--------------------------------------------------------------------------
33+
| Application Force HTTPS
34+
|--------------------------------------------------------------------------
35+
|
36+
| This ariable force the use of HTTPS in the applucation URL
37+
|
38+
*/
39+
40+
'force_https' => env('APP_FORCE_HTTPS', null),
41+
3142
/*
3243
|--------------------------------------------------------------------------
3344
| Application Debug Mode

0 commit comments

Comments
 (0)