Openstatus www.openstatus.dev

wtf: rewrite

+1 -8
+1 -2
apps/web/next.config.js
··· 98 98 source: "/:path*", 99 99 has: [ 100 100 { type: "cookie", key: "sp_mode", value: "new" }, 101 - { type: "cookie", key: "sp_slug", value: "<slug>" }, 102 101 { 103 102 type: "host", 104 103 value: 105 104 "^(?!.*\\.openstatus\\.dev$)(?!openstatus\\.dev$)(?<domain>.+)$", 106 105 }, 107 106 ], 108 - destination: "https://:slug.stpg.dev/:path*", 107 + destination: "https://www.stpg.dev/:domain/:path*", 109 108 }, 110 109 ], 111 110 };
-6
apps/web/src/middleware.ts
··· 71 71 const modeCookie = req.cookies.get("sp_mode")?.value; // "legacy" | "new" 72 72 const cached = modeCookie === "legacy" || modeCookie === "new"; 73 73 let mode: "legacy" | "new" | undefined = cached ? modeCookie : undefined; 74 - let slug: string | undefined = undefined; 75 74 76 75 console.log({ mode, cached }); 77 76 ··· 83 82 console.log({ cache }); 84 83 // Determine legacy flag from cache 85 84 mode = cache ? "new" : "legacy"; 86 - slug = cache ? String(cache) : undefined; 87 85 } catch (e) { 88 86 console.error("error getting cache", e); 89 87 mode = "legacy"; 90 - slug = undefined; 91 88 } 92 89 } 93 90 ··· 103 100 res.headers.set("x-proxy", "1"); 104 101 // Short-lived cookie so toggles apply relatively quickly 105 102 res.cookies.set("sp_mode", "new", { path: "/", maxAge: MAX_AGE }); 106 - if (slug) { 107 - res.cookies.set("sp_slug", slug, { path: "/", maxAge: MAX_AGE }); 108 - } 109 103 // If we just set the cookie, trigger one redirect so next.config.js 110 104 // rewrites that depend on sp_mode can apply on the next request. 111 105 if (!cached) {