chore: change baseURL in fetch session

This commit is contained in:
javayhu 2025-06-21 09:27:22 +08:00
parent 5e1f9167e0
commit 1cb0793a83

View File

@ -3,6 +3,7 @@ import createMiddleware from 'next-intl/middleware';
import { type NextRequest, NextResponse } from 'next/server'; import { type NextRequest, NextResponse } from 'next/server';
import { LOCALES, routing } from './i18n/routing'; import { LOCALES, routing } from './i18n/routing';
import type { Session } from './lib/auth-types'; import type { Session } from './lib/auth-types';
import { getBaseUrl } from './lib/urls/urls';
import { import {
DEFAULT_LOGIN_REDIRECT, DEFAULT_LOGIN_REDIRECT,
protectedRoutes, protectedRoutes,
@ -30,7 +31,7 @@ export default async function middleware(req: NextRequest) {
const { data: session } = await betterFetch<Session>( const { data: session } = await betterFetch<Session>(
'/api/auth/get-session', '/api/auth/get-session',
{ {
baseURL: req.nextUrl.origin, baseURL: getBaseUrl(),
headers: { headers: {
cookie: req.headers.get('cookie') || '', // Forward the cookies from the request cookie: req.headers.get('cookie') || '', // Forward the cookies from the request
}, },