mirror of
https://github.com/vernu/textbee.git
synced 2026-02-20 15:44:31 -05:00
17 lines
530 B
TypeScript
17 lines
530 B
TypeScript
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
|
|
})
|