chore: proxy backend routes via Next rewrites

This commit is contained in:
taDuc
2026-05-10 02:55:45 +07:00
parent b3e765b6f1
commit 0d6599015b
4 changed files with 37 additions and 6 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
import axios, { AxiosError, InternalAxiosRequestConfig } from "axios";
export const baseURL =
process.env.NEXT_PUBLIC_API_URL_ROOT || process.env.NEXT_PUBLIC_API_URL || "http://localhost:3344";
// Prefer same-origin requests. Next.js will proxy API paths via `next.config.ts` rewrites.
export const baseURL = "/";
export const api = axios.create({
baseURL,
@@ -68,7 +68,7 @@ api.interceptors.response.use(
isRefreshing = true;
try {
await axios.post(`${baseURL}/auth/refresh`, undefined, { withCredentials: true });
await axios.post("/auth/refresh", {}, { withCredentials: true });
processQueue(null);