123movies-seo/app/Http/Middleware/RedirectIfInsecure.php

27 lines
580 B
PHP
Raw Permalink Normal View History

2024-08-24 23:08:42 +03:00
<?php
namespace App\Http\Middleware;
use Closure;
class RedirectIfInsecure
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// if not local environment AND the request isn't safe
if (!app()->isLocal() && !$request->secure()) {
// redirect to the mathching secure url
// return redirect()->secure($request->path());
}
return $next($request);
}
}