Black screen in production + canAccessPanel not working
Hello everyone! I encountered a very strange bug in production.
When trying to log in to the panel via an authorized email, I get a black screen and 2 errors in the console related to livewire:
1) The script from "https://example.com/livewire/livewire.min.js?id=38dc8241" was loaded, although its MIME type ("text/html") is not valid for JavaScript.
2) Uncaught SyntaxError: expected expression, got '<'
The strangest thing is that I received these errors when I had @livewireStyles and @livewireScripts in the head and body of the site.
(I have the 'inject_assets' => true option enabled in the config).
The problem is also that anyone can log in via example.com/admin, although User.php has a normally implemented canAccessPanel method.
Code:
User.php:
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasName;
use Filament\Panel;
...
class User extends Authenticatable implements FilamentUser, HasName
{
use HasFactory, Notifiable, SoftDeletes;
protected $fillable = [
'id',
'bio',
'nickname',
'avatar',
'email',
'password',
'provider',
...
];
/**
return $panel
->default()
->favicon(asset('images/logo/favicon.png'))
->id('admin')
->path('admin')
->brandLogo(asset('images/logo/favicon.png'))
->brandLogoHeight('3rem')
->login()
}
...
P.S. I can't insert the whole code because of the limitation, but I can show everything else that is needed without any problems
When trying to log in to the panel via an authorized email, I get a black screen and 2 errors in the console related to livewire:
1) The script from "https://example.com/livewire/livewire.min.js?id=38dc8241" was loaded, although its MIME type ("text/html") is not valid for JavaScript.
2) Uncaught SyntaxError: expected expression, got '<'
The strangest thing is that I received these errors when I had @livewireStyles and @livewireScripts in the head and body of the site.
(I have the 'inject_assets' => true option enabled in the config).
The problem is also that anyone can log in via example.com/admin, although User.php has a normally implemented canAccessPanel method.
Code:
User.php:
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasName;
use Filament\Panel;
...
class User extends Authenticatable implements FilamentUser, HasName
{
use HasFactory, Notifiable, SoftDeletes;
protected $fillable = [
'id',
'bio',
'nickname',
'avatar',
'email',
'password',
'provider',
...
];
/**
- The attributes that should be hidden for serialization.
* - @var list<string>*/protected $hidden = [ 'password',];public function getFilamentName(): string{ return $this->nickname ?? 'admin';}public function canAccessPanel(Panel $panel): bool{ return $this->email === 'crashermoney0@gmail.com';}...
return $panel
->default()
->favicon(asset('images/logo/favicon.png'))
->id('admin')
->path('admin')
->brandLogo(asset('images/logo/favicon.png'))
->brandLogoHeight('3rem')
->login()
}
...
P.S. I can't insert the whole code because of the limitation, but I can show everything else that is needed without any problems