Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.18.0
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

14 changes: 6 additions & 8 deletions src/lib/utilities/request-from-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export const requestFromAPI = async <T>(
let response = await makeRequest();
let { status, statusText } = response;

// Shouldn't this check the expiry on the jwt and refresh before we make a request instead of
// doing a 401? If we get a 401 and we have done all of our refreshes shouldn't we send the user to the login
// page? Asking for a friend (claude)
if (isBrowser && status === 401) {
const refreshed = await refreshTokens();
if (refreshed) {
Expand Down Expand Up @@ -194,14 +197,9 @@ const withBearerToken = async (
): Promise<Record<string, string>> => {
if (!isBrowser) return headers;

try {
const token = await accessToken();
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
/* c8 ignore next 4 */
} catch (e) {
console.error(e);
const token = await accessToken();
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}

return headers;
Expand Down
Loading