From df7dc615532d3441f527374d18664c1a5a336de6 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 21 Jan 2024 21:24:55 -0500 Subject: optional path enforcement and patch baseURL relative inclusion --- lib/vnlib.browser/src/axios/index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/vnlib.browser') diff --git a/lib/vnlib.browser/src/axios/index.ts b/lib/vnlib.browser/src/axios/index.ts index 2780102..6a2135f 100644 --- a/lib/vnlib.browser/src/axios/index.ts +++ b/lib/vnlib.browser/src/axios/index.ts @@ -36,8 +36,23 @@ const configureAxiosInternal = (instance: Axios, session: ISession, tokenHeader: // See if the current session is logged in if (tokenHeaderValue && loggedIn.value) { - // Get an otp for the request - config.headers[tokenHeaderValue] = await generateOneTimeToken(config.url!); + + const path = `${config.baseURL}${config.url}` + + //see if absolute url or relative + if(path.match(/https?:\/\//)){ + //Is absolute + const { pathname } = new URL(path); + + // Get an otp for the request + config.headers[tokenHeaderValue] = await generateOneTimeToken(pathname); + } + else{ + //Is relative + + // Get an otp for the request + config.headers[tokenHeaderValue] = await generateOneTimeToken(path); + } } // Return the config return config -- cgit