Fix E-Mail-Versand und verbessere Fehlerbehandlung
- Behebe Port-Konfiguration für interne RPC-Verbindungen (5173 -> 3000) - Verbessere oRPC-Fehlerbehandlung: ursprüngliche Fehlermeldungen werden beibehalten - Erweitere Frontend-Fehlerbehandlung für bessere oRPC-Integration - Deaktiviere Duplikat-Prüfung in Development-Modus (NODE_ENV=development) - Lokale Entwicklung ermöglicht mehrere Buchungen pro E-Mail-Adresse - Produktion behält Duplikat-Schutz bei
This commit is contained in:
@@ -12,7 +12,8 @@ import { checkBookingRateLimit, getClientIP } from "../lib/rate-limiter.js";
|
||||
import { validateEmail } from "../lib/email-validator.js";
|
||||
|
||||
// Create a server-side client to call other RPC endpoints
|
||||
const link = new RPCLink({ url: "http://localhost:5173/rpc" });
|
||||
const serverPort = process.env.PORT ? parseInt(process.env.PORT) : 3000;
|
||||
const link = new RPCLink({ url: `http://localhost:${serverPort}/rpc` });
|
||||
// Typisierung über any, um Build-Inkompatibilität mit NestedClient zu vermeiden (nur für interne Server-Calls)
|
||||
const queryClient = createORPCClient<any>(link);
|
||||
|
||||
@@ -117,14 +118,17 @@ const create = os
|
||||
}
|
||||
|
||||
// Prevent double booking: same customer email with pending/confirmed on same date
|
||||
const existing = await kv.getAllItems();
|
||||
const hasConflict = existing.some(b =>
|
||||
b.customerEmail.toLowerCase() === input.customerEmail.toLowerCase() &&
|
||||
b.appointmentDate === input.appointmentDate &&
|
||||
(b.status === "pending" || b.status === "confirmed")
|
||||
);
|
||||
if (hasConflict) {
|
||||
throw new Error("Du hast bereits eine Buchung für dieses Datum. Bitte wähle einen anderen Tag oder storniere zuerst.");
|
||||
// Skip duplicate check in development mode
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
const existing = await kv.getAllItems();
|
||||
const hasConflict = existing.some(b =>
|
||||
b.customerEmail.toLowerCase() === input.customerEmail.toLowerCase() &&
|
||||
b.appointmentDate === input.appointmentDate &&
|
||||
(b.status === "pending" || b.status === "confirmed")
|
||||
);
|
||||
if (hasConflict) {
|
||||
throw new Error("Du hast bereits eine Buchung für dieses Datum. Bitte wähle einen anderen Tag oder storniere zuerst.");
|
||||
}
|
||||
}
|
||||
const id = randomUUID();
|
||||
const booking = {
|
||||
|
Reference in New Issue
Block a user