tangled
alpha
login
or
join now
openstatus.dev
/
openstatus
5
fork
atom
Openstatus
www.openstatus.dev
5
fork
atom
overview
issues
pulls
pipelines
middleware hell
thibault.tngl.sh
3 months ago
c9baf7e3
456594c3
+9
-4
1 changed file
expand all
collapse all
unified
split
apps
status-page
src
middleware.ts
+9
-4
apps/status-page/src/middleware.ts
···
133
133
console.log({ url: req.url });
134
134
// const vercelURL = process.env.VERCEL_URL || "www.stpg.dev";
135
135
// console.log({newUrl: vercelURL})
136
136
-
const rewriteUrl = new URL(`${url.pathname}`, `https://${_page.slug}.stpg.dev` );
137
137
-
console.log({ rewriteUrl });
138
138
-
rewriteUrl.search = url.search;
139
139
-
return NextResponse.rewrite(rewriteUrl);
136
136
+
if (pathnames.length > 2) {
137
137
+
138
138
+
const pathname = pathnames.slice(2).join("/");
139
139
+
140
140
+
const rewriteUrl = new URL(`/${pathname}`, `https://${_page.slug}.stpg.dev`);
141
141
+
console.log({ rewriteUrl });
142
142
+
rewriteUrl.search = url.search;
143
143
+
return NextResponse.rewrite(rewriteUrl);
144
144
+
}
140
145
}
141
146
const rewriteUrl = new URL(`/${_page.slug}`, req.url);
142
147
rewriteUrl.search = url.search;