Openstatus www.openstatus.dev

fix: config host value

+21 -9
+8 -2
apps/web/next.config.js
··· 85 85 source: "/_next/:path*", 86 86 has: [ 87 87 { type: "cookie", key: "sp_mode", value: "new" }, 88 - { type: "host", value: "(?<slug>[^.]+)\\.(stpg\\.dev|localhost)" }, 88 + { 89 + type: "host", 90 + value: "(?<slug>[^.]+)\\.(openstatus\\.dev|localhost)", 91 + }, 89 92 ], 90 93 destination: `http://${NEW_HOST}/_next/:path*`, 91 94 }, ··· 94 97 source: "/:path((?!_next/).*)", 95 98 has: [ 96 99 { type: "cookie", key: "sp_mode", value: "new" }, 97 - { type: "host", value: "(?<slug>[^.]+)\\.(stpg\\.dev|localhost)" }, 100 + { 101 + type: "host", 102 + value: "(?<slug>[^.]+)\\.(openstatus\\.dev|localhost)", 103 + }, 98 104 ], 99 105 // NOTE: we don't need the slug `/:slug/:path*` here because it will already be applied in the rewrites in the status-page app as subdomain 100 106 destination: `http://${NEW_HOST}/:path*`,
+13 -7
apps/web/src/middleware.ts
··· 64 64 const pathname = req.nextUrl.pathname; 65 65 const subdomain = getValidSubdomain(host); 66 66 67 + console.log({ subdomain }); 68 + 67 69 // Subdomain handling: set mode cookie (legacy/new) and let next.config rewrites proxy 68 70 if (subdomain) { 69 71 const modeCookie = req.cookies.get("sp_mode")?.value; // "legacy" | "new" 70 72 const cached = modeCookie === "legacy" || modeCookie === "new"; 71 73 let mode: "legacy" | "new" | undefined = cached ? modeCookie : undefined; 74 + 75 + console.log({ mode, cached }); 72 76 73 77 if (!mode) { 74 78 try { ··· 81 85 } 82 86 } 83 87 88 + console.log({ mode }); 89 + 84 90 if (mode === "legacy") { 85 91 url.pathname = `/status-page/${subdomain}${url.pathname}`; 86 92 return NextResponse.rewrite(url); ··· 104 110 } 105 111 106 112 const isPublicAppPath = publicAppPaths.some((path) => 107 - pathname.startsWith(path), 113 + pathname.startsWith(path) 108 114 ); 109 115 110 116 if (!req.auth && pathname.startsWith("/app/invite")) { 111 117 return NextResponse.redirect( 112 118 new URL( 113 119 `/app/login?redirectTo=${encodeURIComponent(req.nextUrl.href)}`, 114 - req.url, 115 - ), 120 + req.url 121 + ) 116 122 ); 117 123 } 118 124 ··· 120 126 return NextResponse.redirect( 121 127 new URL( 122 128 `/app/login?redirectTo=${encodeURIComponent(req.nextUrl.href)}`, 123 - req.url, 124 - ), 129 + req.url 130 + ) 125 131 ); 126 132 } 127 133 ··· 140 146 141 147 if (hasWorkspaceSlug) { 142 148 const hasAccessToWorkspace = allowedWorkspaces.find( 143 - ({ workspace }) => workspace.slug === workspaceSlug, 149 + ({ workspace }) => workspace.slug === workspaceSlug 144 150 ); 145 151 if (hasAccessToWorkspace) { 146 152 const workspaceCookie = req.cookies.get("workspace-slug")?.value; ··· 158 164 const firstWorkspace = allowedWorkspaces[0].workspace; 159 165 const { slug } = firstWorkspace; 160 166 return NextResponse.redirect( 161 - new URL(`/app/${slug}/monitors`, req.url), 167 + new URL(`/app/${slug}/monitors`, req.url) 162 168 ); 163 169 } 164 170 }