/** * Mock backend for screenshot tour. * Returns a valid auth response for any login attempt. * Run: node e2e/mock-backend.mjs */ import http from "node:http" const server = http.createServer((req, res) => { // CORS headers res.setHeader("Access-Control-Allow-Origin", "*") res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization") if (req.method === "OPTIONS") { res.writeHead(204) res.end() return } // Login endpoint if (req.url === "/api/v1/auth/login" && req.method === "POST") { let body = "" req.on("data", (chunk) => (body += chunk)) req.on("end", () => { res.writeHead(200, { "Content-Type": "application/json" }) res.end( JSON.stringify({ accessToken: "mock-jwt-token-for-screenshots", refreshToken: "mock-refresh-token", expiresIn: 3600, member: { id: "1", email: "admin@cannamanage.de", clubName: "Grüner Daumen e.V.", role: "ADMIN", clubId: "club-1", }, }) ) }) return } // Catch-all for other API requests res.writeHead(200, { "Content-Type": "application/json" }) res.end(JSON.stringify({ status: "ok" })) }) server.listen(8080, () => { console.log("🟢 Mock backend running on http://localhost:8080") })