diff --git a/.changeset/dull-rings-arrive.md b/.changeset/dull-rings-arrive.md new file mode 100644 index 0000000000..3e1827dc9c --- /dev/null +++ b/.changeset/dull-rings-arrive.md @@ -0,0 +1,5 @@ +--- +"@blitzjs/auth": patch +--- + +Fixes adding authError query param in Passport adapter. diff --git a/packages/blitz-auth/src/server/passport-adapter.ts b/packages/blitz-auth/src/server/passport-adapter.ts index ccddce1ce9..27f5ea39e9 100644 --- a/packages/blitz-auth/src/server/passport-adapter.ts +++ b/packages/blitz-auth/src/server/passport-adapter.ts @@ -172,8 +172,10 @@ export function passportAuth(config: BlitzPassportConfig): ApiHandler { if (error) { console.error(`Login via ${strategyName} was unsuccessful.`) console.error(error) + + const authErrorQueryStringKey = redirectUrl.includes("?") ? "&authError=" : "?authError="; redirectUrl += - "?authError=" + encodeURIComponent(truncateString(error.toString(), 100)) + authErrorQueryStringKey + encodeURIComponent(truncateString(error.toString(), 100)) res.setHeader("Location", redirectUrl) res.statusCode = 302 res.end()