Initial fullstack project setup with Next.js 15, Gin, PostgreSQL and Docker Compose
- Frontend: Next.js 15 (App Router), Auth.js v5, shadcn/ui, MagicUI - Backend: Go + Gin + GORM with layered architecture - Auth: Local credentials login with optional Keycloak OAuth binding - Admin: RBAC user management for admin role - Dev: Docker Compose with hot reload for both frontend and backend - Docker: 3-service orchestration (frontend, backend, postgres) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
3
frontend/app/api/auth/[...nextauth]/route.ts
Normal file
3
frontend/app/api/auth/[...nextauth]/route.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { GET, POST } from "@/auth";
|
||||
|
||||
export { GET, POST };
|
||||
48
frontend/app/api/proxy/[[...path]]/route.ts
Normal file
48
frontend/app/api/proxy/[[...path]]/route.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { auth } from "@/auth";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
const BACKEND_URL = process.env.SERVER_API_URL || "http://backend:8080";
|
||||
|
||||
async function handler(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ path?: string[] }> }
|
||||
) {
|
||||
const session = await auth();
|
||||
const { path } = await params;
|
||||
const pathStr = path?.join("/") || "";
|
||||
const url = `${BACKEND_URL}/api/${pathStr}${req.nextUrl.search}`;
|
||||
|
||||
const headers = new Headers(req.headers);
|
||||
headers.delete("host");
|
||||
|
||||
if (session?.user) {
|
||||
headers.set("X-User-Id", (session.user as any).id || "");
|
||||
headers.set("X-User-Role", (session.user as any).role || "");
|
||||
}
|
||||
|
||||
const body =
|
||||
req.method === "GET" || req.method === "HEAD"
|
||||
? undefined
|
||||
: await req.arrayBuffer();
|
||||
|
||||
const res = await fetch(url, {
|
||||
method: req.method,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
|
||||
const data = await res.arrayBuffer();
|
||||
|
||||
return new NextResponse(data, {
|
||||
status: res.status,
|
||||
statusText: res.statusText,
|
||||
headers: res.headers,
|
||||
});
|
||||
}
|
||||
|
||||
export const GET = handler;
|
||||
export const POST = handler;
|
||||
export const PUT = handler;
|
||||
export const DELETE = handler;
|
||||
export const PATCH = handler;
|
||||
export const OPTIONS = handler;
|
||||
Reference in New Issue
Block a user