first commit
Made-with: Cursor
This commit is contained in:
30
frontend/app/calendar/route.ts
Normal file
30
frontend/app/calendar/route.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000/api';
|
||||
|
||||
export async function GET() {
|
||||
let upstream: Response;
|
||||
try {
|
||||
upstream = await fetch(`${API_URL}/calendar/ics`, {
|
||||
headers: { Accept: 'text/calendar' },
|
||||
cache: 'no-store',
|
||||
});
|
||||
} catch {
|
||||
return new NextResponse('Calendar service unavailable', { status: 502 });
|
||||
}
|
||||
|
||||
if (!upstream.ok) {
|
||||
return new NextResponse('Failed to fetch calendar', { status: upstream.status });
|
||||
}
|
||||
|
||||
const body = await upstream.text();
|
||||
|
||||
return new NextResponse(body, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'text/calendar; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300',
|
||||
'Content-Disposition': 'inline; filename="bbe-events.ics"',
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user