Laravel Telescope - 403 Forbidden Laravel Telescope - 403 Forbidden laravel laravel

Laravel Telescope - 403 Forbidden


By default, you will only be able to access this dashboard in the local environment.

Within your app/Providers/TelescopeServiceProvider.php file, there is a gate method. This authorization gate controls access to Telescope in non-local environments. You are free to modify this gate as needed to restrict access to your Telescope installation:

/** * Register the Telescope gate. * * This gate determines who can access Telescope in non-local environments. * * @return void */protected function gate(){    Gate::define('viewTelescope', function ($user) {        return in_array($user->email, [            // Your users            'user@yourapp.tld',        ]);    });}


You may override authorization() method in Laravel\Telescope\TelescopeApplicationServiceProvider in your App\Providers\TelescopeServiceProvider and include your enviroment name.

But be careful with it.

/** * Configure the Telescope authorization services. * * @return void */protected function authorization(){    $this->gate();    Telescope::auth(function ($request) {        return app()->environment('local') ||               Gate::check('viewTelescope', [$request->user()]);    });}

to

...return app()->environment(['local', testing]) ||       Gate::check('viewTelescope', [$request->user()]);...


If you use laravel as api application, you can use auth by cookie. Just add cookie secretTelescope and run it.

Gate::define('viewTelescope', function (?User $user) {    return array_key_exists('secretTelescope', $_COOKIE););