fix(server): forward auth error status code to createError#612
Open
noracoderwitch wants to merge 1 commit into
Open
fix(server): forward auth error status code to createError#612noracoderwitch wants to merge 1 commit into
noracoderwitch wants to merge 1 commit into
Conversation
|
@noracoderwitch is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
Description
serverSupabaseUserandserverSupabaseSessioncurrently rethrow Supabase auth errors as plaincreateError({ statusMessage })calls, which defaults the HTTP status to 500. This swallows the actual status that the underlyingAuthErroralready carries.For example, a failed JWT signature verification raises
AuthInvalidJwtErrorwithstatus: 400, a failure insidegetClaims()while fetching JWKS surfaces the upstreamstatus(often 5xx from the Supabase backend), andAuthSessionMissingErrorexposesstatus: 400. With the current code all of those reach the client as a generic 500, which makes it hard to distinguish a legitimate auth failure from a real server fault and noises up error monitoring with false 5xx alerts.This change forwards
error.statuswhen present and falls back to 500 if the error object did not include one (only happens forAuthUnknownErrorand friends). Behavior is unchanged for the success path and for the no-session-no-error path thatgetClaims()already returns null for after the move to JWT signing keys in v2.0.6.Note: this does not address #388, which is about prerender-time
serverSupabaseUserthrowing on missing sessions. That path no longer throws in v2.x since the migration fromgetUser()togetClaims().Checklist: