The POST method is not supported for route admin/login. Supported methods: GET, HEAD.
Hi All,
I was trying to deploy a laravel project on web hosting. My project is correctly run on my local server.
When I deploy on my web hosting by config the env and database connection. everything is good and login form is appear when I route my admin.example.com /public/. But, after i fill correct useremail and password and click the login button (submitting the data), 'Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
"The POST method is not supported for route admin/login. Supported methods: GET, HEAD." Error is Occuring.
I am using Laravel 11, Filament 3 and laravel-sanctum for auth.
I did not use customize form and method for Login and register form for admin dashboard. I use only Filament's login form.
@Tray2 Could you please tell me more detail?
For the first time , when i call my subdomain 'dashboard.example.com' it does not reach to /public and showing the folders. After I made some changes in .htaccess file, the url reach /public automatically when I call my subdomain 'dashboard.example.com'.
Example :
I call, " dashboard.example.com'' it redirect 'dashboard.example.com/public" and show the login form that i redirect in route/web.php. The final route is ' dashboard.example.com/public/admin/login' and it show the login form. but when I submit the user email and password, the error "The POST method is not supported for route admin/login. Supported methods: GET, HEAD." is appear.
The route is work and when i call my subdomain dashboard.example.com it redirect dashboard.example.com/public/admin/login and show the login form..
the error is only show once I submit the user email and password .
My Route -.> Route::get('/', function () {
return redirect(route('filament.admin.auth.login'));
})->name('login');
Is there any suggestion and solution for it.
Thanks
@Tray2 Thanks, now the domain and document root is OK and when i call dashboard.example.com, it redirect to dashboard.example.com/admin/login and show the login form. After, make some changes in configs file and add
' protected $except = [
//
'livewire/*',
];'
in VerifyCsrfToken.php, the POST method not allow and Page expire error does not occur.
But , the issue is change , which is when I login with correct user email and password, the route does not change to /admin and it is redirect to login page.
Thanks for your times and suggestions
sorry for my English writing.
@Advenced-tech-solution Sounds to me like you have made too many changes, and gotten lost. I recommend creating a new project with the proper document root, and then move the code over in small portions.
There is probably something wrong in your code, but it's hidden among all the config changes you've made.
@advenced-tech-solution You normally don't need to change anything when deploying a Laravel app. You don't need to touch .htaccess. You definitely don't need to add CSRF exceptions. It doesn't involve hacking or trying out random stuff. You just need to configure your web server correctly.