Not returning 401 for anonymous users #1342
-
Hello, the behaviour for the "currently logged in user" endpoint is to return a HTTP 401 when the user is not logged in. Apparently, one cannot stop these to got to the browser console log (if this is possible, please tell me). This log "spam" makes it harder to spot actual errors. How do people handle this? Live with the log entry? Override the endpoint to return a 200 and empty result? Or is there a way to suppress the 404 going to the logs? Wrapping in try/catch does not work for me. Best wishes, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Actually, no, that's a browser thing. They'll always log the error in the console, even though we catch it inside the JS code. Personally, I just... live with it. It's worth to note that it'll happen for every errors thrown by your FastAPI app: typically, the 422 errors thrown by Pydantic validation errors will also show up. |
Beta Was this translation helpful? Give feedback.
Actually, no, that's a browser thing. They'll always log the error in the console, even though we catch it inside the JS code.
Personally, I just... live with it. It's worth to note that it'll happen for every errors thrown by your FastAPI app: typically, the 422 errors thrown by Pydantic validation errors will also show up.