Forum: a service of its own and the /forum pages
services/forum (axum, port 8083) on the same database and login, in the forum schema (migration 0038, which also adds the moderator role): nicknames, profiles with shared signs, topics, threads with listening or advice intent, two-level replies, read marks and followed threads, reactions as ratings with points and ranks, newcomer limits (lifted by a purchase), moderation with reasons, bans and a log. Integration tests run in CI. The frontend's /forum pages (light by default, dark on request, phone first with a desktop layout) are switched on by FORUM_URL; the /api/v1 proxy sends /api/v1/forum/* to the forum service. Concept and status: docs/kozosseg.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
// Forwards /api/v1/* to the backend, so the browser talks to one origin and
|
||||
// the session cookie belongs to the frontend's host (no CORS needed).
|
||||
// Forwards /api/v1/* to the backend (and /api/v1/forum/* to the forum
|
||||
// service), so the browser talks to one origin and the session cookie belongs
|
||||
// to the frontend's host (no CORS needed).
|
||||
import { revalidateTag } from "next/cache";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
import { CELEBRITIES_TAG } from "@/lib/celebrities";
|
||||
import { FORUM_URL } from "@/lib/forumServer";
|
||||
import { BACKEND_URL } from "@/lib/server";
|
||||
import { SHARES_TAG } from "@/lib/share";
|
||||
|
||||
@@ -22,7 +24,13 @@ const SKIP_RESPONSE_HEADERS = new Set(["connection", "content-encoding", "conten
|
||||
|
||||
async function forward(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
||||
const { path } = await ctx.params;
|
||||
const target = `${BACKEND_URL}/v1/${path.map(encodeURIComponent).join("/")}${req.nextUrl.search}`;
|
||||
// The forum is a service of its own; without FORUM_URL it is switched off.
|
||||
const forum = path[0] === "forum";
|
||||
if (forum && !FORUM_URL) {
|
||||
return Response.json({ error: { code: "not_found", message: "A fórum nincs bekapcsolva." } }, { status: 404 });
|
||||
}
|
||||
const base = forum ? FORUM_URL : BACKEND_URL;
|
||||
const target = `${base}/v1/${path.map(encodeURIComponent).join("/")}${req.nextUrl.search}`;
|
||||
|
||||
const headers = new Headers();
|
||||
for (const name of REQUEST_HEADERS) {
|
||||
|
||||
Reference in New Issue
Block a user