| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | public function handle(Request $request, Closure $next) |
||
| 11 | { |
||
| 12 | // Check if FORCE_HTTPS is set to true |
||
| 13 | if (env('FORCE_HTTPS') == 'true') { |
||
| 14 | \URL::forceScheme('https'); // Force HTTPS |
||
| 15 | header("Content-Security-Policy: upgrade-insecure-requests"); |
||
| 16 | } |
||
| 17 | |||
| 18 | // Check if FORCE_ROUTE_HTTPS is set to true |
||
| 19 | if (env('FORCE_ROUTE_HTTPS') == 'true' && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off')) { |
||
| 20 | $redirect_url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
| 21 | header("Location: $redirect_url"); |
||
| 22 | exit(); |
||
| 23 | } |
||
| 24 | |||
| 25 | return $next($request); |
||
| 26 | } |
||
| 28 |