-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad request error is thrown instead of AuthenticationError #4207
Comments
Experiencing the same issue on 2.0.0-beta.32. Same blitz version output as @rimselis |
Tested it from |
Same issue on 2.0.0-beta.32. Tested downgrading to [email protected] as commented by Rimselis, and also .beta-31. In both appear but the expected message "Error: You are not authenticated" |
Hey @rimselis, could you add an explicit Superjson registration in your blitz-sever.ts file and check. //blitz-server.ts
...
SuperJson.registerClass(AuthenticationError, {
identifier: "BlitzAuthenticationError",
allowProps: ["name", "message", "code", "statusCode", "meta", "url"],
}) |
I'm on This occurs when I am using Are you sure it was fixed @rodobre ? This is what I see instead of the expected error fallback: |
|
Yes, all packages are updated to 2.0.0-beta.33:
|
The initial issue seems to be fixed with Not sure if I should close this as there are open questions in the comments. |
Not sure what I'm doing wrong then. I'm on Above still doesn't work even if I add the following to SuperJSON.registerClass(AuthenticationError);
SuperJSON.registerClass(AuthorizationError); Can I use |
What is the problem?
Error: Bad request (400) error is thrown when query is set to be authorized.
I have created a simple query on a new project to return an empty array and used it on the index page's
UserInfo
component.When resolver.authorize() is commented out, I can successfully use the query in component
const [users] = useQuery(getUsers, {})
and it returns an empty array with no issues. But when I uncommentresolver.authorize()
, a400: Bad request
error is shown. By default, blitz creates aRootErrorFallback
component to be used inErrorBoundary
component as fallback.RootErrorFallback
component checks for different types of errors:For some reason, the
AuthenticationError
is skipped and the default/fallback else statement is returning theErrorComponent
.On the server-side logs, I can see the correct issue (
[AuthenticationError: You must be logged in to access this] {statusCode: 401}
) being logged, but on the client side it's just anUncaught Error: Bad Request
errorPaste all your error logs here:
Browser console:
Paste all relevant code snippets here:
What are detailed steps to reproduce this?
src/users/queries/getUsers.ts
UserInfo
component viauseQuery
from@blitzjs/rpc
blitz dev
), go to localhost, create a user/login - everything should workresolver.authorize(),
orctx.session.$authorize();
in query fileErrorComponent
will be shown instead ofError: You are not authenticated
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
The text was updated successfully, but these errors were encountered: