refactor: RAPPORT-HOST ist jetzt reines Backend

Das Frontend (Marketing + Login/Konto) ist in RAPPORT-WEBSITE umgezogen
(Hugo + Vanilla-JS). RAPPORT-HOST liefert dessen gebautes public/ statisch
aus und stellt /api bereit.

- server/index.js: serviert RAPPORT-WEBSITE/public + /api (eine Origin)
- server/env.js: websitePublicDir (WEBSITE_PUBLIC_DIR, Default Schwester-Repo);
  PUBLIC_BASE_URL Default auf einheitliche Origin :8787
- billing.js: Checkout-Redirects auf /konto/ bzw. /hosting-preise/
- entfernt: src/ (React), marketing/ (Hugo-Kopie), index.html, vite.config.js
- package.json: nur noch server/migrate/build:website-Scripts

E2E verifiziert: /, /hosting/, /login/, /konto/, /js + Font = 200;
register→checkout(mock)→Instanz; Redirect → /konto/?provisioned=1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 16:41:09 +02:00
parent 07485024cd
commit 13173dddc5
8 changed files with 61 additions and 44 deletions
+4 -1
View File
@@ -23,9 +23,12 @@ const e = process.env;
export const env = {
port: parseInt(e.PORT || "8787", 10),
publicBaseUrl: (e.PUBLIC_BASE_URL || "http://localhost:5273").replace(/\/+$/, ""),
publicBaseUrl: (e.PUBLIC_BASE_URL || "http://localhost:8787").replace(/\/+$/, ""),
jwtSecret: e.JWT_SECRET || "dev-insecure-secret-change-me",
databaseUrl: e.DATABASE_URL || "postgres://rapport_host:rapport_host@localhost:55432/rapport_host",
// Gebautes public/ der RAPPORT-WEBSITE (Hugo). Default: Schwester-Repo lokal.
websitePublicDir: e.WEBSITE_PUBLIC_DIR ||
new URL("../../RAPPORT-WEBSITE/public", import.meta.url).pathname,
stripe: {
secretKey: e.STRIPE_SECRET_KEY || "",
+12 -4
View File
@@ -21,12 +21,20 @@ app.use("/api/auth", authRouter);
app.use("/api/billing", billingRouter);
app.use("/api/account", accountRouter);
// In Produktion liefert dasselbe Backend das gebaute Frontend aus (dist/).
const dist = path.resolve(__dirname, "..", "dist");
app.use(express.static(dist));
// ── Statische Auslieferung der RAPPORT-WEBSITE (Hugo-Build) ──────────────────
// Die komplette Frontend-Oberfläche (Marketing + Hosting + Login/Konto als
// Vanilla-JS-Seiten) kommt aus dem AGPL-Repo RAPPORT-WEBSITE. Dieses Backend
// liefert dessen gebautes public/ aus und stellt darunter /api bereit.
// Saubere Trennung: die Website enthält keinen Backend-Code, nur fetch('/api').
// Pfad per WEBSITE_PUBLIC_DIR überschreibbar (Default: Schwester-Repo).
const websitePublic = env.websitePublicDir;
app.use(express.static(websitePublic));
app.get("*", (req, res, next) => {
if (req.path.startsWith("/api/")) return next();
res.sendFile(path.join(dist, "index.html"), (err) => err && next());
// Hugo erzeugt pro Seite eine eigene index.html → Clean-URLs funktionieren
// direkt über express.static. Unbekannte Pfade → 404-Seite.
res.status(404).sendFile(path.join(websitePublic, "404.html"), (err) => err && next());
});
// Express-Fehlerhandler: fängt synchron geworfene Fehler aus Routen → 500
+3 -3
View File
@@ -61,7 +61,7 @@ billingRouter.post("/checkout", requireAuth, async (req, res) => {
status: "active",
periodEnd: new Date(Date.now() + 30 * 864e5),
});
return res.json({ mock: true, url: `${env.publicBaseUrl}/dashboard?provisioned=1` });
return res.json({ mock: true, url: `${env.publicBaseUrl}/konto/?provisioned=1` });
}
// ── Stripe-Checkout-Session ──────────────────────────────────────────────
@@ -72,8 +72,8 @@ billingRouter.post("/checkout", requireAuth, async (req, res) => {
customer_email: req.account.email,
client_reference_id: req.account.id,
metadata: { accountId: req.account.id, planId: plan.id },
success_url: `${env.publicBaseUrl}/dashboard?provisioned=1`,
cancel_url: `${env.publicBaseUrl}/plans?canceled=1`,
success_url: `${env.publicBaseUrl}/konto/?provisioned=1`,
cancel_url: `${env.publicBaseUrl}/hosting-preise/?canceled=1`,
});
res.json({ url: session.url });
} catch (err) {