F
Filament4mo ago
B2

The POST method is not supported for route admin/login for custom login page

Hello, I have an issue with a custom login page in Laravel 11 with Filament 3. When I submit the form, I get the error: "The POST method is not supported for route admin/login. Supported methods: GET, HEAD." Here’s my setup: Custom Login Class
class Login extends BaseAuth
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.auth.login';
protected static string $layout = 'filament.layouts.layout-login';

public function form(Form $form): Form
{
return $form
->schema([
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data');
}
}
class Login extends BaseAuth
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.auth.login';
protected static string $layout = 'filament.layouts.layout-login';

public function form(Form $form): Form
{
return $form
->schema([
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data');
}
}
Added to AdminPanelProvider
public function panel(Panel $panel): Panel
{
return $panel
->login(Login::class);
}
public function panel(Panel $panel): Panel
{
return $panel
->login(Login::class);
}
Custom Template
<x-filament-panels::page.simple>
<x-filament-panels::form id="form" wire:submit="authenticate">
{{ $this->form }}
<x-filament-panels::form.actions :actions="$this->getCachedFormActions()" />
</x-filament-panels::form>
</x-filament-panels::page.simple>
<x-filament-panels::page.simple>
<x-filament-panels::form id="form" wire:submit="authenticate">
{{ $this->form }}
<x-filament-panels::form.actions :actions="$this->getCachedFormActions()" />
</x-filament-panels::form>
</x-filament-panels::page.simple>
Despite this, the error persists. Is there something I missed in the configuration? Thanks for your help!
6 Replies
B2
B2OP4mo ago
It seems that the issue is related to my custom layout.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="h-full bg-white">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel</title>

<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet"/>

@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
@vite(['resources/css/app.css', 'resources/js/app.js'])

@endif
</head>

<body class="h-full">
@yield('content')

@vite('resources/js/app.js')
</body>
</html>
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="h-full bg-white">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel</title>

<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet"/>

@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
@vite(['resources/css/app.css', 'resources/js/app.js'])

@endif
</head>

<body class="h-full">
@yield('content')

@vite('resources/js/app.js')
</body>
</html>
When I remove it, the login works perfectly, but the CSS does not render as expected. Any ideas?
Eugen Pașca
Eugen Pașca4mo ago
the error you get "The POST method is not supported for route admin/login. Supported methods: GET, HEAD" means that livewire/livewire.js is not loaded. or at least this happens for me. the problem you are facing is that livewire/livewire.js is a route and your server tries to load it as a file. Try to check the vhost config or try to publish the livewire files. in my case the problem from vhost was this line . If you remove the JS from that list it would work. But i think the vendor:publish method is better
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}
php artisan vendor:publish --force --tag=livewire:assets
B2
B2OP4mo ago
Hello 👋 , I tried publishing the Livewire files, but it still doesn't work 😬
Amir
Amir3mo ago
Hi everyone I have this problem too and check all thoses help but non of them helped me Could you please help me to find out what’s the issue that cause my problem? Did your problem get solved? @bryan.labielle
ludaima
ludaima4w ago
i got a error like this😩
No description
LeandroFerreira
GitHub
Getting "The POST method is not supported for route admin/login. Su...
Package Panel builder Package Version v3.0.0 How can we help you? I've recently deployed my Filament application to a server, but I'm encountering an error message stating 'The POST met...

Did you find this page helpful?