Skip to content

Commit

Permalink
修复 issue vitejs#5265
Browse files Browse the repository at this point in the history
  • Loading branch information
4jia1 committed Dec 18, 2021
1 parent aab303f commit c4586f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export interface ServerOptions extends CommonServerOptions {
* Origin for the generated asset URLs.
*/
origin?: string
/**
* disable dot rule to support dot in route
*/
disableDotRule?: boolean
}

export interface ResolvedServerOptions extends ServerOptions {
Expand Down Expand Up @@ -531,7 +535,7 @@ export async function createServer(

// spa fallback
if (!middlewareMode || middlewareMode === 'html') {
middlewares.use(spaFallbackMiddleware(root))
middlewares.use(spaFallbackMiddleware(root, serverConfig.disableDotRule))
}

// run post config hooks
Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/node/server/middlewares/spaFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { Connect } from 'types/connect'
import { createDebugger } from '../../utils'

export function spaFallbackMiddleware(
root: string
root: string,
disableDotRule: boolean = false
): Connect.NextHandleFunction {
const historySpaFallbackMiddleware = history({
logger: createDebugger('vite:spa-fallback'),
disableDotRule,
// support /dir/ without explicit index.html
rewrites: [
{
Expand Down

0 comments on commit c4586f5

Please sign in to comment.