Skip to content

Commit 233ebcf

Browse files
committed
fix(auth): handle custom Cognito domains without appending regional suffix
Ensure fullDomainPath uses the custom domain as-is when provided, falling back to the Cognito-managed domain construction only if no custom domain exists. This resolves malformed OAuth redirect URLs when using imported Cognito resources with SSO.
1 parent f74ad0b commit 233ebcf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/backend-auth/src/lambda/reference_auth_initializer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@ export class ReferenceAuthInitializer {
459459

460460
// domain
461461
const oauthDomain = userPool.CustomDomain ?? userPool.Domain ?? '';
462-
const fullDomainPath = `${oauthDomain}.auth.${region}.amazoncognito.com`;
462+
const fullDomainPath = userPool.CustomDomain
463+
? userPool.CustomDomain
464+
: `${oauthDomain}.auth.${region}.amazoncognito.com`;
463465
const data = {
464466
signupAttributes: JSON.stringify(
465467
userPool.SchemaAttributes?.filter(

0 commit comments

Comments
 (0)