I have testet laravel Horizon on my local environment and everything is working as expected. When I am switching to production domain/horizon throws a 403 error. I have set the gate in HorizonServiceProvider as stated in the documentation - First step is just to get access without auth. My gate now looks like this:
{
Gate::define('viewHorizon', function ($user = null) {
return true;
});
}
Can anyone suggest what I am missing?
link to 403 error link to 401 error - Dashboard without data
Check this GitHub comment: https://github.com/laravel/horizon/issues/563#issuecomment-480882947
You may have to register Horizon's service provider.
In config/app.php
:
'providers' => [
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
...
App\Providers\TelescopeServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
],
The error it's because horizon it's first go to the boot method, so i recommended you in your HorizonServiceProvider.php edit the boot method to allow your request like this:
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
Horizon::auth(function ($request) {
if ($request->ajax()){
return true;
}
else if (isset($request->let_me_go) && $request->let_me_go == 'ok'){
return true;
}else{
throw new UnauthorizedHttpException('Unauthorized');
}
});
}
So when you will go to your production server need to pass the parameter like this:
my-production-site.com/horizon/dashboard?let_me_go=ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With