Files
mintel.me/apps/web/app/errors/api/relay/route.ts
T
mmintelandClaude Opus 5.5 75993100fa feat: German as the main language, English under /en, with a language switch
The site now exists in German (at the root, with /impressum and /datenschutz)
and English (/en). A request without a language follows the visitor's choice
from the language switch, then the browser language, then German; the old
English legal addresses move to /en for good.

All visible texts are data in src/content/de.ts and en.ts, so components hold
none of their own. The header carries a DE/EN switch whose bit curtain covers
the page while it is swapped and reopens at the same reading position. Title,
description, canonical, hreflang, Open Graph, the share image, the sitemap and
the structured data are per language. The privacy notice now describes the
cookie that remembers the chosen language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:07:22 +02:00

56 lines
1.6 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { env } from "@/lib/env";
/**
* Smart Proxy / Relay for Sentry/GlitchTip events.
*
* Mirroring the klz-2026 pattern:
* Receives Sentry envelopes from the client, injects the correct DSN,
* and forwards them to GlitchTip.
*/
export async function POST(request: NextRequest) {
try {
const envelope = await request.text();
const realDsn = env.SENTRY_DSN;
if (!realDsn) {
console.warn(
"[Sentry Relay] Received payload but no SENTRY_DSN configured",
);
return NextResponse.json({ status: "ignored" }, { status: 200 });
}
const dsnUrl = new URL(realDsn);
const projectId = dsnUrl.pathname.replace("/", "");
const relayUrl = `${dsnUrl.protocol}//${dsnUrl.host}/api/${projectId}/envelope/`;
const response = await fetch(relayUrl, {
method: "POST",
body: envelope,
headers: {
"Content-Type": "application/x-sentry-envelope",
},
});
if (!response.ok) {
const errorText = await response.text();
console.error("[Sentry Relay] GlitchTip API responded with error", {
status: response.status,
error: errorText.slice(0, 100),
});
return new NextResponse(errorText, { status: response.status });
}
return NextResponse.json({ status: "ok" });
} catch (error) {
console.error("[Sentry Relay] Failed to relay Sentry request", {
error: (error as Error).message,
});
return NextResponse.json(
{ error: "Internal Server Error" },
{ status: 500 },
);
}
}