Enable auth-service/api-gateway on production, build their images in CI

This commit is contained in:
2026-08-18 14:11:00 +07:00
parent e5afedfa2f
commit b68005be1c
70 changed files with 6781 additions and 263 deletions
+30
View File
@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import type { AuthUser } from "@duoc-thu/shared-types";
import { SESSION_COOKIE } from "../session";
const GATEWAY_URL = process.env.API_GATEWAY_URL ?? "http://localhost:3000";
export async function GET() {
const token = cookies().get(SESSION_COOKIE)?.value;
if (!token) {
return NextResponse.json({ error: "not_authenticated" }, { status: 401 });
}
let upstream: Response;
try {
upstream = await fetch(`${GATEWAY_URL}/auth/me`, {
headers: { Authorization: `Bearer ${token}` },
cache: "no-store",
});
} catch {
return NextResponse.json({ error: "gateway_unreachable" }, { status: 502 });
}
if (!upstream.ok) {
return NextResponse.json({ error: "not_authenticated" }, { status: 401 });
}
const user = (await upstream.json()) as AuthUser;
return NextResponse.json(user);
}