Route server requests through local API

Use BASE_URL_API_LOCAL_SERVER for server-side data requests and load the layout session through the cached helper. Update production URLs to HTTPS and use 127.0.0.1 for local API endpoints.
This commit is contained in:
Ichsan Kurniawan
2026-11-10 17:23:53 +07:00
parent b329a89f2d
commit aa99536a32
5 changed files with 12 additions and 12 deletions
+4 -4
View File
@@ -4,10 +4,10 @@ import { logger } from "./logger"
import { getCacheServerSession } from "./get-access-data"
export default async function fetchData(url: string = '/', cache: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" = 'default', next?: NextFetchRequestConfig) {
const { BASE_URL_API } = process.env
const baseUrl = process.env.BASE_URL_API_LOCAL_SERVER
const session = await getCacheServerSession()
const res = await fetch(BASE_URL_API + url, {
const res = await fetch(baseUrl + url, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session?.user.access_token}`,
@@ -32,10 +32,10 @@ export default async function fetchData(url: string = '/', cache: "default" | "f
}
export async function fetchDataWithPost(url: string = '/', payload: any = {}, cache: "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload" = 'default', next?: NextFetchRequestConfig) {
const { BASE_URL_API } = process.env
const baseUrl = process.env.BASE_URL_API_LOCAL_SERVER
const session = await getCacheServerSession()
const res = await fetch(BASE_URL_API + url, {
const res = await fetch(baseUrl + url, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session?.user.access_token}`,