I have a basePathname defined in the qwikCity options in vite.config.ts. I expect visiting the dev server with the base pathname will load my app but I just get a 404 page instead.
The built express server seems to still function properly.
I tried this fix (by manually editing the node modules):
diff --git a/packages/qwik-city/buildtime/vite/dev-server.ts b/packages/qwik-city/buildtime/vite/dev-server.ts
index d8ed56c4..13e7ec59 100644
--- a/packages/qwik-city/buildtime/vite/dev-server.ts
+++ b/packages/qwik-city/buildtime/vite/dev-server.ts
@@ -30,8 +30,9 @@ import { formatError } from './format-error';
export function ssrDevMiddleware(ctx: BuildContext, server: ViteDevServer) {
const matchRouteRequest = (pathname: string) => {
+ const fullPathname = ctx.opts.basePathname + pathname.slice(1);
for (const route of ctx.routes) {
- const match = route.pattern.exec(pathname);
+ const match = route.pattern.exec(fullPathname);
if (match) {
return {
route,
@@ -40,10 +41,10 @@ export function ssrDevMiddleware(ctx: BuildContext, server: ViteDevServer) {
}
}
- if (ctx.opts.trailingSlash && !pathname.endsWith('/')) {
- const pathnameWithSlash = pathname + '/';
+ if (ctx.opts.trailingSlash && !fullPathname.endsWith('/')) {
+ const fullPathnameWithSlash = fullPathname + '/';
for (const route of ctx.routes) {
- const match = route.pattern.exec(pathnameWithSlash);
+ const match = route.pattern.exec(fullPathnameWithSlash);
if (match) {
return {
route,
and from what I can tell the dev server is good now. Unfortunately devcontainer isn't working properly on M1 macs (I believe?) so I can't get an actual build from the qwik repo. I'm happy to put up a PR but I can't easily test it right now.
This was working properly back with qwik-city beta versions.
Which component is affected?
Qwik City (routing)
Describe the bug
I have a
basePathname
defined in theqwikCity
options invite.config.ts
. I expect visiting the dev server with the base pathname will load my app but I just get a 404 page instead.The built express server seems to still function properly.
Reproduction
https://stackblitz.com/edit/qwik-starter-wphjat?file=vite.config.ts
Steps to reproduce
basePathname: 'foo'
option to theqwikCity
middleware invite.config.ts
.http://localhost:5173/foo/
. You should get a 404System Info
Additional Information
I tried this fix (by manually editing the node modules):
and from what I can tell the dev server is good now. Unfortunately devcontainer isn't working properly on M1 macs (I believe?) so I can't get an actual build from the qwik repo. I'm happy to put up a PR but I can't easily test it right now.
This was working properly back with qwik-city beta versions.