telescope: Could not get it to work for non-local environment
At first, i’d like to appreciate your efforts in producing such an amazing package.
I’ve updated the Gate::define
method to return always true
Nothing is being logged to telescope. telescope entries table is empty, although I made sure the all flags in config/telescope
is set to true.
Any clue where the problem could be ?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 40 (2 by maintainers)
in my side, i found the problem was on its Authorization mechanism. so, we can replace it with our own auth mechanisme. now, mine is:
in
config/telescope.php
Remove this from the register function
The problem appears to be the following method in
TelescopeApplicationServiceProvider
:I overrode this method in my
TelescopeServiceProvider
and defined my own auth closure:This allowed me to access telescope in my staging environment. I tried changing my
gate()
override and it didn’t appear to work. This was the only way that I could reliably get it to work.Changed the Authorize middleware by my own as following:
It fixed the 403 Forbidden on a production server. Used with the removal of the Telescope::filter, it fixed the whole thing for me.
Guys, we’d love to help but we aren’t able to reproduce this.
So, here are some guidelines/checks:
Telescope::filter
orTelescope::filterBatch
call in yourApp\Providers\TelescopeServiceProvider
? If yes, does it satisfy the filter condition? The defaultTelescopeServiceProvider
stub allows all entries to be recorded in local environments but for production only allows reportable exceptions, failed jobs, scheduled tasks and monitored tag entries to be recorded.authorization
pass through? The defaultauthorization
method in theTelescopeServiceProvider
stub always passes for local environments but does the gate check for production.Laravel\Telescope\TelescopeServiceProvider
in yourconfig/app.php
?App\Providers\TelescopeServiceProvider
to yourconfig/app.php
?TELESCOPE_ENABLED
if set. Defaults to true if not set.If all of these are okay but you’re still facing issues, please share a Github repo with this reproducible issue.
I am not sure if it’s only me or it is a bug but, i think i found the issue. The problem is it doesn’t discover
App\Providers\TelescopeServiceProvider::class,
So addingApp\Providers\TelescopeServiceProvider::class,
inconfig/app.php
fixes it. Then i can set in.env
fileand in
app\Providers\TelescopeServiceProvider.php
then without any issue i can reach
/telescope
with the useradmin@admin.com
logged in.As @glendmaatita says I did a middleware exclusively for telescope // telescope.php
php artisan make:middleware TelescopeMiddleware
@Braunson number 2 seems to be your issue. Your filter is setup to only record reportable exceptions, failed jobs, scheduled tasks or monitored tags in production but will record everything in local. If you remove the
Telescope::filter
callback, everything should be recorded.+1 I got 403 Forbidden in Production even if the Gate returns always true
Same here! It works when I use
APP_ENV=local
.I tried @dramen solution but It didn’t worked for me.
app.php
TelescopeServiceProvider.php
This issue is due to an empty or non logged user. Laravel gate receives user as the first argument if it’s empty it doesn’t care about internal code. If you want to use it without gate just remove gate function from TelescopeServiceProvider class and override authorization function. See the example below.
I removed the gate define as well as gate check, so the issue is resolved.
excuse me I can not connect to the dashboard with a non
local env
Changing telescope authorization middleware with laravel’s authentication middleware worked for me. It’s just a workaround.
I can solve it by rewrite authorization method
Telescope’s gate can run right when
Auth::user()
had value. So,if you didn’t login,you could not view telescope in production. You can rewriteAuthorize::class
, likereturn config('telescope.enabled') ? $next($request) : abort(403);
.Thanks, i just comment ‘Authorize::class’
If you’ve been following the instructions in the section “Installing Only In Specific Environments” you’ll need to ensure that you update your
AppServiceProvider
accordingly, e.g.I’m having this issue as well now, as of 13 days ago. Requests aren’t being logged (among other things) in a production environment anymore.
+1, can’t connect the dashboard with production env.