diff --git a/src/middleware/auth/authMiddleware.ts b/src/middleware/auth/authMiddleware.ts index 47665b0..73f3694 100644 --- a/src/middleware/auth/authMiddleware.ts +++ b/src/middleware/auth/authMiddleware.ts @@ -13,11 +13,11 @@ export function initAuthMiddleware(initParams: AuthMiddlewareParams) { getHeaders, handleAuthError, } = initParams; - const sanitizedUrl = typeof url === 'function' ? url() : url; return async (...params: Parameters) => { const [options, meta] = params; const currentSessionTokens = getTokens(); + const sanitizedUrl = typeof url === 'function' ? await url() : url; const headers = typeof getHeaders === 'function' ? getHeaders(meta) : diff --git a/src/middleware/auth/types.d.ts b/src/middleware/auth/types.d.ts index 945db5a..755c3f5 100644 --- a/src/middleware/auth/types.d.ts +++ b/src/middleware/auth/types.d.ts @@ -1,5 +1,5 @@ export interface AuthMiddlewareParams { - url: string | (() => string); + url: string | (() => Promise); method?: RequestInit['method']; errorCodes?: Response['status'][]; getTokens: (tokens?: unknown) => { accessToken: string; refreshToken: string };