From 827b10b1f9951b76239c3bf4bbffc00911c310e7 Mon Sep 17 00:00:00 2001 From: Vben Date: Mon, 22 Mar 2021 10:25:04 +0800 Subject: [PATCH] feat(serve): support request carries .(DOT) character fix #2415, fix #2628 --- docs/config/index.md | 9 +++++++++ packages/vite/src/node/server/index.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/config/index.md b/docs/config/index.md index 86a6b7ca41a81f..72d2e2111a0f31 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -403,6 +403,15 @@ export default ({ command, mode }) => { File system watcher options to pass on to [chokidar](https://github.com/paulmillr/chokidar#api). +### server.disableDotRule + +- **Type:** `boolean` +- **Default:** `false` + + Allow .(DOT) character in the request path. + + Set to `true` to allow requests to carry .(DOT) character. + ## Build Options ### build.target diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index ce1743d2ad2076..1b8edc2d7f294a 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -120,6 +120,14 @@ export interface ServerOptions { * Should start and end with the `/` character */ base?: string + + /** + * uses https://github.com/bripkens/connect-history-api-fallback#disabledotrule + * Note: Allow .(DOT) character in the request path. + * Set to `true` to allow requests to carry .(DOT) character + * default: false + */ + disableDotRule?: boolean } /** @@ -436,6 +444,7 @@ export async function createServer( if (!middlewareMode) { middlewares.use( history({ + disableDotRule: !!serverConfig.disableDotRule, logger: createDebugger('vite:spa-fallback'), // support /dir/ without explicit index.html rewrites: [