Skip to content

Commit a525d08

Browse files
committed
feat: add token set to xhr client
1 parent ae492c7 commit a525d08

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/templates/core/xhr/getHeaders.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptio
66
resolve(options, config.HEADERS),
77
]);
88

9+
if (!isStringWithValue(token)) {
10+
const SESSION_KEY = '_anyroad_embedded_session_key';
11+
token = document?.cookie?.split('; ').find(row => row.startsWith(`${SESSION_KEY}=`))?.split('=')[1];
12+
}
13+
914
const headers = Object.entries({
1015
Accept: 'application/json',
1116
...additionalHeaders,

0 commit comments

Comments
 (0)