How to handle Route [login] not defined error
i want customize filament error Route [login] not defined error when posting in postman
14 Replies
Define a login route that redirects to Filaments login route. See this discord.
Your issue with Postman is probably that you are not logged in.
i am using postman for creating token and use that token for authentication. If the token I am giving is write then no issue arises but when I am giving wrong token the laravel error is coming up and I want to change that error as my requirements.
The error comes up because you aren't authenticated and Laravel tries to redirect you to the login page which isn't defined.
my requirement is to change that error instead of laravel error it should return authentication failure or anything that I can change
Where is your route defined?
in the api.php?
Your setup is probably already wrong since API request shouldn't redirect to a Login page.
Check your Laravel setup. This is unrelated to Filament
yes in api.php
Can you check the middlewares?
php artisan route:list -vvv
Probably Authenticate is applied
Oh, did you also set the Accept header to applicaiton/json?yes i have used laravel:sanctum
for creating token and then go for authentication
my requirement is only to customize the error which is coming
Please provide some information and code. What request do you send? What's the endpoint/middelware/...?
Again: This error should not appear if your setup was right.
yes I want the error should appear because I knowingly give the wrong token but as my requirement when the error is coming it is not understandable for other users who don't know filament so I want that erroe should come but in a way that other can understand
So I want to change that error .in stead of
In stead of filament error it sould give a error that i gave in backend
did you also set the Accept header to application/json?
Seems like they want an error response when accidentally hitting a non-API route, right? I this case you could try writing a middleware to intercept any request that come from your JS client.
yes