Skip to content

Commit 3113059

Browse files
authored
fix(clerk-js): pass proxyUrl to createFapiClient (#4990)
1 parent 8a8eb6d commit 3113059

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

.changeset/mighty-otters-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Fix an issue where Clerk's `proxyUrl` was not being respected.

packages/clerk-js/src/core/__tests__/clerk.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,19 @@ describe('Clerk singleton', () => {
20802080
});
20812081
});
20822082

2083+
describe('proxyUrl', () => {
2084+
describe('when proxyUrl is set', () => {
2085+
test('fapiClient should use Clerk.proxyUrl as its baseUrl', async () => {
2086+
const sut = new Clerk(productionPublishableKey, {
2087+
proxyUrl: 'https://proxy.com/api/__clerk',
2088+
});
2089+
await sut.load({});
2090+
2091+
expect(sut.getFapiClient().buildUrl({ path: '/me' }).href).toContain('https://proxy.com/api/__clerk/v1/me');
2092+
});
2093+
});
2094+
});
2095+
20832096
describe('buildUrlWithAuth', () => {
20842097
it('builds an absolute url from a relative url in development', async () => {
20852098
const sut = new Clerk(developmentPublishableKey);

packages/clerk-js/src/core/clerk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ export class Clerk implements ClerkInterface {
314314
getSessionId: () => {
315315
return this.session?.id;
316316
},
317+
proxyUrl: this.proxyUrl,
317318
});
318319
// This line is used for the piggy-backing mechanism
319320
BaseResource.clerk = this;

pnpm-lock.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)