Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Http/Middleware/PreventRegularBrowserAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class PreventRegularBrowserAccess
{
public function handle(Request $request, Closure $next)
{
if (! config('nativephp-internal.running')) {
return $next($request);
}

// Explicitly skip for the cookie-setting route
if ($request->path() === '_native/api/cookie') {
return $next($request);
Expand Down
7 changes: 7 additions & 0 deletions src/NativeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Application;
use Illuminate\Foundation\Application as Foundation;
use Illuminate\Foundation\Http\Kernel;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
Expand All @@ -23,6 +24,7 @@
use Native\Laravel\Events\EventWatcher;
use Native\Laravel\Exceptions\Handler;
use Native\Laravel\GlobalShortcut as GlobalShortcutImplementation;
use Native\Laravel\Http\Middleware\PreventRegularBrowserAccess;
use Native\Laravel\Logging\LogWatcher;
use Native\Laravel\PowerMonitor as PowerMonitorImplementation;
use Native\Laravel\Windows\WindowManager as WindowManagerImplementation;
Expand Down Expand Up @@ -84,6 +86,11 @@ public function packageRegistered()
Handler::class
);

// Automatically prevent browser access
$this->app->make(Kernel::class)->pushMiddleware(
PreventRegularBrowserAccess::class,
);

Application::starting(function ($app) {
$app->resolveCommands([
LoadStartupConfigurationCommand::class,
Expand Down
Loading