Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tasty-socks-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Prevent infinite loop when the client is blocked
5 changes: 4 additions & 1 deletion packages/clerk-js/src/core/resources/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ export abstract class BaseResource {
const message = errors?.[0]?.long_message;
const code = errors?.[0]?.code;

const isCaptchaRequired = code === 'requires_captcha';
const isClientEndpointBlocked = requestInit.path === '/client' && code === 'resource_forbidden';

// if the status is 401, we need to handle unauthenticated as we did before
// otherwise, we are going to ignore the requires_captcha error
// as we're going to handle it by triggering the captcha challenge
if (status === 401 && code !== 'requires_captcha') {
if (status === 401 && !isCaptchaRequired && !isClientEndpointBlocked) {
await BaseResource.clerk.handleUnauthenticated();
}

Expand Down