How to handle Route [login] not defined error

i want customize filament error Route [login] not defined error when posting in postman
14 Replies
Dennis Koch
Dennis Koch11mo ago
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.
majestic_hamster_97459
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.
Dennis Koch
Dennis Koch11mo ago
The error comes up because you aren't authenticated and Laravel tries to redirect you to the login page which isn't defined.
majestic_hamster_97459
my requirement is to change that error instead of laravel error it should return authentication failure or anything that I can change
veldmuizie
veldmuizie11mo ago
Where is your route defined? in the api.php?
Dennis Koch
Dennis Koch11mo ago
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
majestic_hamster_97459
yes in api.php
veldmuizie
veldmuizie11mo ago
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?
majestic_hamster_97459
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
Dennis Koch
Dennis Koch11mo ago
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.
majestic_hamster_97459
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
veldmuizie
veldmuizie11mo ago
did you also set the Accept header to application/json?
Dennis Koch
Dennis Koch11mo ago
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.
Want results from more Discord servers?
Add your server
More Posts