separate local and client api calls
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
PORT=6001
|
||||
VERCEL_PROJECT_PRODUCTION_URL=http://localhost:6001
|
||||
LOCAL_API_BASE_URL=http://localhost:6001/api
|
||||
NEXT_PUBLIC_API_BASE_URL=http://localhost:6001/api
|
||||
+1
-1
@@ -31,7 +31,7 @@ yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
.env
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:4000/api',
|
||||
baseURL: process.env.LOCAL_API_BASE_URL || 'http://localhost:4000/api',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
withCredentials: true, // Enable sending cookies with requests
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
api.interceptors.request.use(
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const clientApi = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:4000/api',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
clientApi.interceptors.request.use(
|
||||
(config) => {
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
);
|
||||
|
||||
export default clientApi;
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from '@/lib/axios';
|
||||
import clientApi from '@/lib/client-axios';
|
||||
|
||||
interface Payload {
|
||||
first_name: string;
|
||||
@@ -9,5 +9,5 @@ interface Payload {
|
||||
}
|
||||
|
||||
export async function setContact(payload: Payload) {
|
||||
await api.post('/contact', payload);
|
||||
await clientApi.post('/contact', payload);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user