Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel https middleware

namespace AppHttpMiddleware;

use Closure;
use IlluminateSupportFacadesApp;

class HttpsProtocolMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (!$request->secure() && app()->environment('production')) {
            return redirect()->secure($request->getRequestUri());
        }

        return $next($request);
    }
}

#then in Http/Kernel

protected $middlewareGroups = [
    'web' => [
       AppHttpMiddlewareEncryptCookies::class,
       IlluminateCookieMiddlewareAddQueuedCookiesToResponse::class,
       IlluminateSessionMiddlewareStartSession::class,
       //IlluminateSessionMiddlewareAuthenticateSession::class,
       IlluminateViewMiddlewareShareErrorsFromSession::class,
       AppHttpMiddlewareVerifyCsrfToken::class,
       IlluminateRoutingMiddlewareSubstituteBindings::class,
       AppHttpMiddlewareHttpsProtocolMiddleware::class
    ],

    'api' => [
        'throttle:60,1',
        'bindings',
    ],
];
Comment

PREVIOUS NEXT
Code Example
Php :: Show All Categories as Links 
Php :: how to login first before see index php 
Php :: php increment variable 
Php :: best custom email validation rule for laravel 
Php :: how to add x-xss-protection header 
Php :: check multiple roles with Blade directive @can? 
Php :: woocommerce unset custom checkout field 
Php :: database connection in pdo php 
Php :: create config value file in php 
Php :: create resource controller in admin folder laravel 
Php :: laravel dirty words check 
Php :: How to create routes in the codeigniter 
Php :: conditional validation laravel based on role 
Php :: app url laravel 
Php :: yii2 activeform adding field css class 
Php :: apt-get install php wordpress extensions 
Php :: change sender name laravel 
Php :: laravel storage get filename 
Php :: date in russian php 
Php :: Get the current script file name 
Php :: wordpress query a post by id 
Php :: laravel repository update multiple row 
Php :: laravel return a single dimensional array 
Php :: no sass folder in laravel 
Php :: Define memory limit in PHP 
Php :: sum of each group in laravel 
Php :: split date range into weeks php 
Php :: How to go back to the main page in php 
Php :: php header author 
Php :: php convert accented characters to html entities 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =