From 992debb6039d29dfcd3a89e1b962d7e97b6303c9 Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Wed, 25 Feb 2026 11:07:46 +0330 Subject: [PATCH] feat(api): update API configuration and add proxy rewrites - Remove the NEXT_PUBLIC_API_URL from the production environment file. - Change axios base URL to use a local proxy endpoint. - Add rewrites in next.config.mjs to route API requests through the proxy. --- .env.production | 1 - next.config.mjs | 22 +++++++++++++++------- src/lib/api/axios.ts | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.env.production b/.env.production index c06dd94..50765b3 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,3 @@ -NEXT_PUBLIC_API_URL="https://admin.opplenz.com/admin/v1/" NEXT_PUBLIC_TOAST_AUTO_CLOSE_DURATION=2500 NEXT_PUBLIC_FIREBASE_API_KEY=AIzaSyCTjdsk2jE34IfnvSKP1JMTIf_Abd7tbt0 NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=opplens-270d1.firebaseapp.com diff --git a/next.config.mjs b/next.config.mjs index d237698..bc2eaf7 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -6,25 +6,33 @@ const nextConfig = { { protocol: "https", hostname: "cdn.sanity.io", - port: "" + port: "", }, { protocol: "https", hostname: "lh3.googleusercontent.com", - port: "" + port: "", }, { protocol: "https", hostname: "avatars.githubusercontent.com", - port: "" + port: "", }, { protocol: "https", hostname: "pub-b7fd9c30cdbf439183b75041f5f71b92.r2.dev", - port: "" - } - ] - } + port: "", + }, + ], + }, + async rewrites() { + return [ + { + source: "/api/proxy/:path*", + destination: `https://admin.opplenz.com/admin/v1/:path*`, + }, + ]; + }, }; export default nextConfig; diff --git a/src/lib/api/axios.ts b/src/lib/api/axios.ts index a8b9bd9..23c6d8e 100644 --- a/src/lib/api/axios.ts +++ b/src/lib/api/axios.ts @@ -9,7 +9,7 @@ import { import axios from "axios"; const api = axios.create({ - baseURL: process.env.NEXT_PUBLIC_API_URL, + baseURL: "/api/proxy/", timeout: 10000, headers: { "Content-Type": "application/json",