Skip to content

fix(router): serve static files under the configured base path - #9010

Merged
maiieul merged 1 commit into
QwikDev:mainfrom
akasakariko:fix-static-base-pathname
Sep 18, 2026
Merged

maiieul merged 1 commit into
QwikDev:mainfrom
akasakariko:fix-static-base-pathname

Conversation

@akasakariko

Copy link
Copy Markdown
Contributor

What is it?

  • Bug

Description

Fixes #8812.

With a base such as /docs/, a request for /docs/hello.txt can be recognized as static but is read from dist/docs/hello.txt, while the file is actually at dist/hello.txt. Build and asset directory prefixes also omit the base.

Use the configured base for build/asset classification, then strip it at the filesystem boundary in the Node, Deno, and Bun middleware. Preserve full URL paths in the prerendered-path lookup and keep the existing trailing-slash behavior. Deno and Bun derive the filename from the stripped pathname too.

Filesystem access still follows static-path eligibility checks, and the base must match at a slash boundary. Encoded path segments remain encoded.

The focused suite covers public files, nested bases, root/index pages, both trailing-slash modes, build/assets without manifest entries, and paths outside the base. All 50 tests pass; restoring the original production implementations produces 23 failures.

Validation:

  • pnpm build.core and the Router TypeScript check pass.
  • Changed-file ESLint, Prettier, and diff checks pass.
  • The package unit suite passes with one existing loopback-socket test excluded: 3673 passed, 20 skipped (19 existing skips plus that exclusion), and 19 todo. The excluded test is should make Node response progress before render completes; this environment does not permit its localhost listener.
  • Deno/Bun adapter tests use real filesystem-backed API shims under Node. Native runtime and browser E2E tests were not run.

Checklist

@akasakariko
akasakariko requested a review from a team as a code owner September 14, 2026 02:41
@changeset-bot

changeset-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ecd66ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@qwik.dev/router Patch
eslint-plugin-qwik Patch
create-qwik Patch
@qwik.dev/devtools Patch
@qwik.dev/react Patch
@qwik.dev/utils Patch
@qwik.dev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@9010

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@9010

@qwik.dev/utils

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/utils@9010

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@9010

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@9010

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@9010

@qwik.dev/devtools

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/devtools@9010

commit: ecd66ba

@maiieul

maiieul commented Sep 18, 2026

Copy link
Copy Markdown
Member

Thanks @KayanoLiam

LGTM

@maiieul
maiieul merged commit 7f5ee58 into QwikDev:main Sep 18, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐞] staticFile middlewares don't strip basePathname before file resolution

2 participants