To allow unauthenticated users to access a custom Filament page, you need to override the default authentication middleware for that specific page. By default, Filament applies authentication middleware to all admin panel pages.
Here’s how you can make your CreateMaintenanceRequestsForm page accessible to unauthenticated users:
- Override the Middleware in Your Page Class
In your CreateMaintenanceRequestsForm page class, override the getMiddleware() method to remove the authentication middleware:
use Filament\Pages\Page;
class CreateMaintenanceRequestsForm extends Page
{
// ... your existing code
public static function getMiddleware(): array
{
// Only apply web middleware, not auth
return ['web'];
}
}
- Register the Page Route Manually (Optional but Recommended)
If you want this page to be accessible outside the admin panel route group, you can register a route for it in your routes/web.php:
use App\Filament\Pages\CreateMaintenanceRequestsForm;
Route::get('/maintenance-request', CreateMaintenanceRequestsForm::class)
->name('maintenance-request');
- Access the Page
Now, unauthenticated users should be able to access /maintenance-request without being redirected to the login page.
Note:
- If your page uses Filament resources/components that require authentication, you may need to adjust their logic to handle guests.
- Be cautious about exposing sensitive admin functionality to unauthenticated users.
Summary:
Override getMiddleware() in your page class to remove the auth middleware, and optionally register a public route for your page. This will allow unauthenticated users to access it.