fix: handle subdomain URLs that already include space prefix
When accessing demo.rspace.online/demo/rcart/pay/123, the subdomain router was prepending the space again, creating /demo/demo/rcart/pay/123 which returned 404. Now detects when first path segment matches the subdomain and passes through without double-prefixing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8040c30756
commit
988fc4f893
|
|
@ -2405,6 +2405,14 @@ const server = Bun.serve<WSData>({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If first segment already matches the subdomain (space slug),
|
||||||
|
// pass through directly — URL already has /{space}/... prefix
|
||||||
|
// e.g. demo.rspace.online/demo/rcart/pay/123 → /demo/rcart/pay/123
|
||||||
|
if (pathSegments[0].toLowerCase() === subdomain) {
|
||||||
|
const rewrittenUrl = new URL(url.pathname + url.search, `http://localhost:${PORT}`);
|
||||||
|
return app.fetch(new Request(rewrittenUrl, req));
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize module ID to lowercase (rTrips → rtrips)
|
// Normalize module ID to lowercase (rTrips → rtrips)
|
||||||
const normalizedPath = "/" + pathSegments.map((seg, i) =>
|
const normalizedPath = "/" + pathSegments.map((seg, i) =>
|
||||||
i === 0 ? seg.toLowerCase() : seg
|
i === 0 ? seg.toLowerCase() : seg
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue