Skip to content

Commit 755e346

Browse files
committed
fix auth
1 parent 90576e1 commit 755e346

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

auth.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function createTrpcClient(debug: boolean, deployUrl: string) {
6262
errorLink,
6363
retryLink({
6464
retry({ error: err }) {
65-
if (err.message !== "Unauthorized") {
65+
if (!(err?.data?.code !== "NOT_AUTHENTICATED" && err?.data?.code !== "TOKEN_EXPIRED")) {
6666
return false;
6767
}
6868

@@ -95,6 +95,16 @@ export function createTrpcClient(debug: boolean, deployUrl: string) {
9595
code: -32004,
9696
data: { httpStatus: 401, code: "NOT_AUTHENTICATED" },
9797
});
98+
} else if (response.status === 403) {
99+
const body = await response.clone().json();
100+
console.log(body);
101+
if (body.code === "TOKEN_EXPIRED") {
102+
throw TRPCClientError.from({
103+
message: "Token Expired",
104+
code: -32004,
105+
data: { httpStatus: 401, code: "TOKEN_EXPIRED" },
106+
});
107+
}
98108
}
99109
return response;
100110
},

0 commit comments

Comments
 (0)