Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vampiremr's avatar

403 forbidden in Laravel Nova

I use Laravel 10.1.5 and Nova 4.22.1 When in .env APP_ENV=local all ok But when APP_ENV=production I see error 403 on my admin/login page

I try to write

    Gate::define('viewNova', function ($user) {
        return in_array($user->email, [
            'myrealemail'
        ]);
    });

in NovaServiceProvider.php but nothigt

How I can fix it for production?

0 likes
5 replies
Talinon's avatar

@vampiremr in_array is case sensitive, so you might want to first start off by checking that.

Talinon's avatar

@vampiremr What if you returned true just to test if the gate is being called?

Or just add something temporary like this and check your storage/log file

protected function gate()
{
    Gate::define('viewNova', function ($user) {
		\Log::info('called viewNova gate!');
		return true;
//        return in_array($user->email, [
//            'myrealemail'
//        ]);
    });
}
vampiremr's avatar

I found that problem in laravel permission module But I still don't know how to fix it

Eloïse's avatar

Hello I'm facing the same problem after upgrading to Nova 4 in laravel 9, did you solve your problem and how ? Thx ;)

Please or to participate in this conversation.