Skip to content

Instantly share code, notes, and snippets.

@edgrosvenor
Created February 12, 2021 17:46
Show Gist options
  • Save edgrosvenor/7fd1ae5c528c604fe21236ba6e30afe7 to your computer and use it in GitHub Desktop.
Save edgrosvenor/7fd1ae5c528c604fe21236ba6e30afe7 to your computer and use it in GitHub Desktop.
I register this as a route middleware in any app I build to keep me from enabling my really hacky shortcuts in production.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class LocalOnly
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
abort_unless(config('app.env') === 'local', 404);
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment