diff options
author | vnugent <public@vaughnnugent.com> | 2024-01-21 21:24:55 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-01-21 21:24:55 -0500 |
commit | df7dc615532d3441f527374d18664c1a5a336de6 (patch) | |
tree | 67819af288284e399a5749bbd61d99c9c895c3e1 /lib/vnlib.browser | |
parent | d396d5b58a2be0efa307e0e656efb40fa12c024d (diff) |
optional path enforcement and patch baseURL relative inclusion
Diffstat (limited to 'lib/vnlib.browser')
-rw-r--r-- | lib/vnlib.browser/src/axios/index.ts | 19 |
1 files changed, 17 insertions, 2 deletions
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 |