Download frontend/src/app/api/feedback/route.ts from new-arc/vector: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/src/app/api/feedback/route.ts
- Command line
-
hf download hf://spaces/new-arc/vector/frontend/src/app/api/feedback/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/src/app/api/feedback/route.ts
1.12 kB
| import { headers } from "next/headers"; | |
| import { NextResponse } from "next/server"; | |
| import { auth } from "@/lib/auth"; | |
| import { buildBackendAuthHeaders } from "@/lib/backend-auth"; | |
| import { backendTraceHeaders } from "@/server/backend-api"; | |
| export async function POST(request: Request) { | |
| const session = await auth.api.getSession({ headers: await headers() }); | |
| if (!session?.user?.id) { | |
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | |
| } | |
| const payload = await request.text(); | |
| const apiUrl = | |
| process.env.BACKEND_INTERNAL_URL || | |
| process.env.NEXT_PUBLIC_API_URL || | |
| "http://localhost:8000"; | |
| const upstream = await fetch(`${apiUrl}/feedback`, { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| ...buildBackendAuthHeaders(session.user.id), | |
| ...(await backendTraceHeaders()), | |
| }, | |
| body: payload, | |
| }); | |
| const responseText = await upstream.text(); | |
| return new NextResponse(responseText, { | |
| status: upstream.status, | |
| headers: { | |
| "Content-Type": upstream.headers.get("content-type") || "application/json", | |
| }, | |
| }); | |
| } | |