vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
67.99k stars 6.12k forks source link

Blocks path although server proxy applies #16389

Open Trombecher opened 6 months ago

Trombecher commented 6 months ago

Describe the bug

I am building a client for my file server and need to serve the same index.html for almost every path. Precisely, I am using server.proxy to map each path matching "/D:*" to "/" via vite.config.ts like this:

import {defineConfig} from "vite";

export default defineConfig({
    // ... other options
    server: {
        proxy: {
            "/D:*": "/"
        }
    }
});

But if I try to access http://localhost:5173/D:/Images, it restricts access because D:/Images (folder) exists. This is not unique to this folder; any path that exists is getting blocked, while paths that are not found just resolve to "/". This should not happen since the URL is getting remapped.

Reproduction

https://stackblitz.com/edit/vitejs-vite-kchmac?file=vite.config.js

Steps to reproduce

Run npm run dev and navigate to the URL with pathname /@fs/bin.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
    Memory: 42.84 GB / 63.93 GB
  Binaries:
    Node: 21.7.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.5 - ~\AppData\Local\pnpm\pnpm.EXE
    bun: 1.1.3 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (123.0.2420.81)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Logs

No response

Validations

stackblitz[bot] commented 6 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.