Skip to content

Latest commit

 

History

History
21 lines (21 loc) · 501 Bytes

middleware-redirect-to-pwa.md

File metadata and controls

21 lines (21 loc) · 501 Bytes
<?php
namespace App\Http\Middleware;
use Closure;
class RedirectRequestsToPWA
{
    /**
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
    	if(!$request->isRoute('pwa') && $request->method() === 'GET' && !$request->isXmlHttpRequest()){
		    return redirect(route('pwa').'/'.$request->path());
	    }
	    return $next($request);
    }
}