Laravel Filament 3 生产环境(Heroku)后台登录页面404问题求助
Laravel Filament 3 生产环境(Heroku)后台登录页面404问题求助
大家好,我现在遇到一个头疼的问题:本地开发环境下,Laravel Filament 3的后台登录页面(/admin/login)能正常访问和使用,但部署到Heroku生产环境后,访问这个路径就会出现404错误。我已经折腾了好一阵,还是没解决,想请各位大佬帮忙看看!
我已经尝试过的操作
- 配置了
.htaccess文件来处理路由重写 - 新增了Heroku所需的
Procfile - User模型已经正确实现
FilamentUser接口,并且在canAccessPanel方法里返回了true - 通过
php artisan route:list确认admin/login路由确实存在 - 执行了缓存清除操作(包括
optimize:clear)
相关代码片段
.htaccess 文件
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Procfile 文件
web: vendor/bin/heroku-php-apache2 public/ release: php artisan optimize:clear
User 模型代码
<?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Tymon\JWTAuth\Contracts\JWTSubject; use Filament\Models\Contracts\FilamentUser; use Filament\Panel; class User extends Authenticatable implements JWTSubject, FilamentUser { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'admin', 'username', 'practice_id', 'role_id', 'is_disabled', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; public function role() { return $this->belongsTo('App\Role'); } public function getJWTIdentifier() { return $this->getKey(); } public function getJWTCustomClaims(): array { return []; } public function setSettingsAttribute($value) { if (is_string($value)) { $value = collect(json_decode($value, true)); } parent::setSettingsAttribute($value); } public function toArray() { return array_merge(parent::toArray(), [ 'role' => $this->role, 'roles' => $this->roles, 'practice' => $this->practice, ]); } public function canAccessPanel(Panel $panel): bool { return true; } }
实在是找不到问题出在哪了,有没有朋友遇到过类似的情况?或者有什么排查方向可以给我指一下?万分感谢!
内容来源于stack exchange
相关产品推荐
相关产品推荐

