Skip to content

Vite strips base URL from request #9234

@benmccann

Description

@benmccann

Describe the bug

Vite strips the base URL to avoid other middlewares from having to worry about the base URL:

req.url = url.replace(devBase, '/')

Unfortunately, it doesn't really save us from having to worry about the base path and creates a number of broken / unexpected behaviors. E.g. our 404 messages print Not found: /whatever instead of Not found: /basepath/whatever.

While SvelteKit could change its own middleware, that's impossible off-the-shelf middlewares that users might. Some examples that are broken with Vite:

SvelteKit does not use Vite's static asset serving because of this, but I'd love just use Vite's instead of recreating our own

Reproduction

req.url = url.replace(devBase, '/')

System Info

`main`

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changep2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions