Skip to content

Commit 566f7af

Browse files
dimklmsakbar
andcommitted
fix(clerk-js): Update redirection FAPI Accounts to include accountstage
Co-authored-by: Shehzad Akbar <akbar.shehzad@gmail.com>
1 parent 5957a3d commit 566f7af

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

.changeset/proud-sheep-doubt.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/backend/src/redirections.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,21 @@ export default (QUnit: QUnit) => {
306306
redirectAdapterSpy.calledWith(`https://included.katydid-92.accounts.dev/sign-up?redirect_url=${encodedUrl}`),
307307
);
308308
});
309+
310+
test('returns path based url with development (kima) publishableKey (with staging Clerk) but without signUpUrl to redirectToSignUp', assert => {
311+
const redirectAdapterSpy = sinon.spy(_url => 'redirectAdapterValue');
312+
const { redirectToSignUp } = redirect({
313+
redirectAdapter: redirectAdapterSpy,
314+
publishableKey: 'pk_test_aW5jbHVkZWQua2F0eWRpZC05Mi5jbGVyay5hY2NvdW50c3N0YWdlLmRldiQ',
315+
});
316+
317+
const result = redirectToSignUp({ returnBackUrl });
318+
assert.equal(result, 'redirectAdapterValue');
319+
assert.ok(
320+
redirectAdapterSpy.calledWith(
321+
`https://included.katydid-92.accountsstage.dev/sign-up?redirect_url=${encodedUrl}`,
322+
),
323+
);
324+
});
309325
});
310326
};

packages/backend/src/redirections.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ function buildAccountsBaseUrl(frontendApi?: string) {
7373
}
7474

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

0 commit comments

Comments
 (0)