account settings and account creation
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
const API_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:8080";
|
||||
|
||||
function passthroughHeaders(req: Request) {
|
||||
const h = new Headers();
|
||||
const auth = req.headers.get("authorization");
|
||||
if (auth) h.set("authorization", auth);
|
||||
h.set("content-type", req.headers.get("content-type") ?? "application/json");
|
||||
return h;
|
||||
}
|
||||
|
||||
export async function GET(req: Request) {
|
||||
const upstream = await fetch(`${API_BASE_URL}/api/v1/users/me`, {
|
||||
method: "GET",
|
||||
headers: passthroughHeaders(req),
|
||||
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" },
|
||||
});
|
||||
}
|
||||
|
||||
export async function PATCH(req: Request) {
|
||||
const body = await req.text().catch(() => "");
|
||||
|
||||
const upstream = await fetch(`${API_BASE_URL}/api/v1/users/me`, {
|
||||
method: "PATCH",
|
||||
headers: passthroughHeaders(req),
|
||||
body,
|
||||
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" },
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user