MCPcopy
hub / github.com/vitejs/vite / checkLoadingAccess

Function checkLoadingAccess

packages/vite/src/node/server/middlewares/static.ts:329–342  ·  view source on GitHub ↗
(
  config: ResolvedConfig,
  path: string,
)

Source from the content-addressed store, hash-verified

327}
328
329export function checkLoadingAccess(
330 config: ResolvedConfig,
331 path: string,
332): 'allowed' | 'denied' | 'fallback' {
333 if (isFileLoadingAllowed(config, slash(path))) {
334 return 'allowed'
335 }
336 if (isFileReadable(path)) {
337 return 'denied'
338 }
339 // if the file doesn't exist, we shouldn't restrict this path as it can
340 // be an API call. Middlewares would issue a 404 if the file isn't handled
341 return 'fallback'
342}
343
344export function respondWithAccessDenied(
345 id: string,

Callers 4

indexHtmlMiddlewareFunction · 0.90
transformMiddlewareFunction · 0.90
sirvOptionsFunction · 0.85

Calls 3

slashFunction · 0.90
isFileReadableFunction · 0.90
isFileLoadingAllowedFunction · 0.85

Tested by

no test coverage detected