Files
shadow-gunbuilder-ai-proto/app/api/users/me/username-available/route.ts
T
2026-01-23 21:40:16 -05:00

27 lines
790 B
TypeScript

import { NextResponse } from "next/server";
const API_BASE_URL =
process.env.NEXT_PUBLIC_API_BASE_URL ?? "";
export async function GET(req: Request) {
const url = new URL(req.url);
const username = url.searchParams.get("username") ?? "";
const auth = req.headers.get("authorization") ?? "";
const upstream = await fetch(
`${API_BASE_URL}/api/v1/users/me/username-available?username=${encodeURIComponent(username)}`,
{
method: "GET",
headers: {
...(auth ? { authorization: auth } : {}),
},
cache: "no-store",
}
);
const text = await upstream.text().catch(() => "");
return new NextResponse(text, {
status: upstream.status,
headers: { "content-type": upstream.headers.get("content-type") ?? "application/json" },
});
}