Tricks

Admin panel 403 in production

May 30, 2022
Dan Harrin
Admin panel, FAQ

If you've deployed your Filament admin panel to a non-local environment and you're receiving 403 Forbidden errors when trying to access it, it's likely that you've forgotten to set up your User model to access Filament.

You must implement the FilamentUser contract:

<?php
 
namespace App\Models;
 
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Foundation\Auth\User as Authenticatable;
 
class User extends Authenticatable implements FilamentUser
{
// ...
 
public function canAccessFilament(): bool
{
return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}
}

The canAccessFilament() method returns true or false depending on whether the user is allowed to access Filament. In this example, we check if the user's email ends with @yourdomain.com and if they have verified their email address.

You can find this information in our documentation.

avatar
Julio Cesar Daza Urbina

I have tried this a thousand times, and no matter what I do, I still get the same 403 forbidden error on DigitalOcean Apps. I need help because I need to go into production and I can't figure it out.

👍 1
avatar

Hi, This maybe unrelated but I got this to work ok on digital ocean droplets using the devdojo laravel 10 marketplace offering. Not sure about the apps...

When adding filament, did you create a filament user? :)

avatar

public function hasVerifiedEmail() { return ! is_null($this->email_verified_at); }

avatar

Hello, I am experiencing the same issue. Were you able to solve it?

avatar

Don't forget to add class User extends Authenticatable implements FilamentUser