20 lines
751 B
TypeScript
20 lines
751 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { buildBackendRequestHeaders } from "@/lib/backend-auth";
|
|
|
|
const API_BASE = process.env.POLYWEATHER_API_BASE_URL;
|
|
|
|
export async function GET(req: NextRequest) {
|
|
if (!API_BASE) {
|
|
return new NextResponse("API not configured", { status: 500 });
|
|
}
|
|
const isCards = req.nextUrl.searchParams.get("cards") === "1";
|
|
const path = isCards ? "/m/cards" : "/m";
|
|
const auth = await buildBackendRequestHeaders(req, { includeSupabaseIdentity: false });
|
|
const res = await fetch(`${API_BASE}${path}`, { headers: auth.headers });
|
|
const html = await res.text();
|
|
return new NextResponse(html, {
|
|
status: res.status,
|
|
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
});
|
|
}
|