砍掉 /m HTML 页面,只保留 /m/json 给 React 组件用
This commit is contained in:
@@ -5,19 +5,9 @@ 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 });
|
||||
return NextResponse.json({ error: "API not configured" }, { status: 500 });
|
||||
}
|
||||
const isCards = req.nextUrl.searchParams.get("cards") === "1";
|
||||
const asJson = req.nextUrl.searchParams.get("json") === "1";
|
||||
const path = asJson ? "/m/json" : isCards ? "/m/cards" : "/m";
|
||||
const auth = await buildBackendRequestHeaders(req, { includeSupabaseIdentity: false });
|
||||
const res = await fetch(`${API_BASE}${path}`, { headers: auth.headers });
|
||||
if (asJson) {
|
||||
return NextResponse.json(await res.json());
|
||||
}
|
||||
const html = await res.text();
|
||||
return new NextResponse(html, {
|
||||
status: res.status,
|
||||
headers: { "Content-Type": "text/html; charset=utf-8" },
|
||||
});
|
||||
const res = await fetch(`${API_BASE}/m/json`, { headers: auth.headers });
|
||||
return NextResponse.json(await res.json());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user