19 lines
577 B
TypeScript
19 lines
577 B
TypeScript
import {H3Event} from "h3";
|
|
import Client from "~/utils/api/client";
|
|
|
|
export const ServerApi = (event: H3Event) => {
|
|
const {apiUrl} = useRuntimeConfig().public;
|
|
const accessToken = getCookie(event, 'Authorization');
|
|
const refreshToken = getCookie(event, 'Refresh-Token');
|
|
|
|
console.log(`Access Token: ${accessToken}`);
|
|
console.log(`Refresh Token: ${refreshToken}`);
|
|
|
|
const client = new Client(apiUrl as string, {
|
|
headers: {
|
|
'Authorization': `Bearer ${accessToken}`,
|
|
'Refresh-Token': `Bearer ${refreshToken}`
|
|
} as HeadersInit
|
|
})
|
|
return client;
|
|
} |