Skip to content

Commit

Permalink
fix(clerk-js): Update redirection FAPI Accounts to include accountstage
Browse files Browse the repository at this point in the history
Co-authored-by: Shehzad Akbar <akbar.shehzad@gmail.com>
  • Loading branch information
dimkl and msakbar committed Jun 29, 2023
1 parent 5957a3d commit 566f7af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .changeset/proud-sheep-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
16 changes: 16 additions & 0 deletions packages/backend/src/redirections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,21 @@ export default (QUnit: QUnit) => {
redirectAdapterSpy.calledWith(`https://included.katydid-92.accounts.dev/sign-up?redirect_url=${encodedUrl}`),
);
});

test('returns path based url with development (kima) publishableKey (with staging Clerk) but without signUpUrl to redirectToSignUp', assert => {
const redirectAdapterSpy = sinon.spy(_url => 'redirectAdapterValue');
const { redirectToSignUp } = redirect({
redirectAdapter: redirectAdapterSpy,
publishableKey: 'pk_test_aW5jbHVkZWQua2F0eWRpZC05Mi5jbGVyay5hY2NvdW50c3N0YWdlLmRldiQ',
});

const result = redirectToSignUp({ returnBackUrl });
assert.equal(result, 'redirectAdapterValue');
assert.ok(
redirectAdapterSpy.calledWith(
`https://included.katydid-92.accountsstage.dev/sign-up?redirect_url=${encodedUrl}`,
),
);
});
});
};
5 changes: 4 additions & 1 deletion packages/backend/src/redirections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function buildAccountsBaseUrl(frontendApi?: string) {
}

// convert url from FAPI to accounts for Kima and legacy (prod & dev) instances
const accountsBaseUrl = frontendApi.replace(/(clerk\.accounts\.|clerk\.)/, 'accounts.');
const accountsBaseUrl = frontendApi
// staging accounts
.replace(/(clerk\.accountsstage\.)/, 'accountsstage.')
.replace(/(clerk\.accounts\.|clerk\.)/, 'accounts.');
return `https://${accountsBaseUrl}`;
}

0 comments on commit 566f7af

Please sign in to comment.