fix(frontend): resolve API base URL at request time for production
Use same-origin /api in the browser so builds are not stuck with baked-in localhost. Server-side fetches use INTERNAL_API_URL, NEXT_PUBLIC_API_URL, or loopback. Centralize logic in lib/api-base.ts. Made-with: Cursor
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000/api';
|
||||
import { apiUrl } from '@/lib/api-base';
|
||||
|
||||
export async function GET() {
|
||||
let upstream: Response;
|
||||
try {
|
||||
upstream = await fetch(`${API_URL}/calendar/ics`, {
|
||||
upstream = await fetch(apiUrl('/calendar/ics'), {
|
||||
headers: { Accept: 'text/calendar' },
|
||||
cache: 'no-store',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user