mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 12:06:29 +00:00
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:
+4
-4
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user