Skip to content

When using a base path, resources should not be served without the base path #5656

@Artur-

Description

@Artur-

Describe the bug

If you use e.g.

    base:'/basepath/'

then curl localhost:3000/basepath/src/main.ts should return src/main.ts but
curl localhost:3000/src/main.ts should return 404.

Right now

localhost:3000/src/main.ts

returns a HTML page in the browser, saying you probably meant localhost:3000/basepath/src/main.ts but if you request the resource from a script, it is happily served

Reproduction

https://github.com/Artur-/vite-vaadin-problem5

npm i
npm run dev

curl localhost:3000/src/main.ts should return 404

System Info

System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 108.13 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2021.10.04.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 93.1.29.81
    Chrome: 95.0.4638.69
    Chrome Canary: 98.0.4701.0
    Firefox: 93.0
    Safari: 15.1
    Safari Technology Preview: 15.4
  npmPackages:
    vite: ^2.6.4 => 2.6.14

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions