You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
530 B
16 lines
530 B
import axios from 'axios'
|
|
import { getServerSession } from 'next-auth/next'
|
|
import { authOptions } from '@/lib/auth'
|
|
import { Session } from 'next-auth'
|
|
|
|
export const httpServerClient = axios.create({
|
|
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || '',
|
|
})
|
|
|
|
httpServerClient.interceptors.request.use(async (config) => {
|
|
const session: Session | null = await getServerSession(authOptions as any)
|
|
if (session?.user?.accessToken) {
|
|
config.headers.Authorization = `Bearer ${session.user.accessToken}`
|
|
}
|
|
return config
|
|
})
|