telescope: Always returns 403 in production

Won’t work for me in production no matter what:

    'middleware' => [
        'web',
//        Authorize::class,
    ],
    public function register()
    {
        // Telescope::night();

        $this->hideSensitiveRequestDetails();

//        Telescope::filter(function (IncomingEntry $entry) {
//            if ($this->app->isLocal()) {
//                return true;
//            }
//
//            return $entry->isReportableException() ||
//                   $entry->isFailedJob() ||
//                   $entry->isScheduledTask() ||
//                   $entry->hasMonitoredTag();
//        });
    }
    protected function gate()
    {
        Gate::define('viewTelescope', function ($user) {
            return true;
        });
    }
    protected function authorization()
    {
        $this->gate();

        Telescope::auth(function ($request) {
            return true;
        });
    }

APP_ENV=local // changed from production to see if that worked
TELESCOPE_ENABLED=true

In production always gives me 403, thought the database entries are all being created.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Have the same problem. Whatever I do it gives me 403 in production environment. In local works. Laravel 6.9.0, Telescope 2.1

I have the same problem, it always returns a 403 error even I set the Gate::define returns true and config cache was cleared. Any solution for that?

I am having the exact same issue, but for me it doesn’t work even with config:cache.

I have tried clearing the cache manually from bootstrap/cache and from storage/framework.

If you don’t use Laravel authorization, modify function ($user) to function ($user = null)

protected function gate()
    {
        Gate::define('viewTelescope', function ($user = null) {
            /*return in_array($user->email, [
                //
            ]);*/
            return true;
        });
    }

Running the command php artisan config:cache fixed the issue.

Interestingly when I toggle TELESCOPE_ENABLED=false between true and false on my Laravel forge instance it won’t take effect unless I run composer dumpautoload && php artisan config:cache.

So it seems there is some caching going on here causing many problems with Laravel Telescope

My Telescope instance was working on prod (with custom IP whitelisting) with Laravel 5.8 but once I upgraded to 7.0 it started returning a 403. Here’s my gate…

       Gate::define('viewTelescope', function ($user = null) {
            if (! in_array(request()->ip(), explode(',', config('nova.ipWhiteList')))) {
                abort(403);
            }
            return true;
        });

@phuclh @RuanHerculano I have managed to get it working. I’ve updated to the latest release 2.0.6 and double checked my user email. Now it works. I can swear that before it would not work no matter what.