feat: Initialize project
This commit is contained in:
1 parent
eccc32337f
commit
3c1050898e
65 files changed
+5661
-596
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
|
||||
const client = axios.create({
|
||||
baseURL: `${process.env.NODE_ENV === 'development' ? 'http://' : 'https://'}${
|
||||
process.env.NEXT_PUBLIC_VERCEL_URL
|
||||
}/api`,
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
const handleResponse = (response: AxiosResponse): AxiosResponse['data'] => response.data;
|
||||
|
||||
client.interceptors.response.use(handleResponse);
|
||||
|
||||
client.interceptors.request.use(async (config) => {
|
||||
if (typeof window !== 'undefined') return config;
|
||||
|
||||
const { cookies } = await import('next/headers');
|
||||
|
||||
config.headers.set('Cookie', cookies().toString());
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
export default client;
|
||||
Reference in new issue
Block a user