Home / Function/ isFileLoadingAllowed() — vite Function Reference

isFileLoadingAllowed() — vite Function Reference

Architecture documentation for the isFileLoadingAllowed() function in static.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  b5f75f2b_ae88_b9ce_360f_813018b7842e["isFileLoadingAllowed()"]
  d91d6c8f_e2c2_3b92_12c3_391c9ba06183["static.ts"]
  b5f75f2b_ae88_b9ce_360f_813018b7842e -->|defined in| d91d6c8f_e2c2_3b92_12c3_391c9ba06183
  a29ea500_1ac9_5bca_45d3_fc9f72429363["isFileServingAllowed()"]
  a29ea500_1ac9_5bca_45d3_fc9f72429363 -->|calls| b5f75f2b_ae88_b9ce_360f_813018b7842e
  fe25e7e9_e8e7_d04f_5c4c_9b4e6daa8350["checkLoadingAccess()"]
  fe25e7e9_e8e7_d04f_5c4c_9b4e6daa8350 -->|calls| b5f75f2b_ae88_b9ce_360f_813018b7842e
  bdac5327_5085_933f_41df_0fc270134a38["loadAndTransform()"]
  bdac5327_5085_933f_41df_0fc270134a38 -->|calls| b5f75f2b_ae88_b9ce_360f_813018b7842e
  2c797df0_6f8d_bb30_24cf_3a4eff202dbc["isFileInTargetPath()"]
  b5f75f2b_ae88_b9ce_360f_813018b7842e -->|calls| 2c797df0_6f8d_bb30_24cf_3a4eff202dbc
  style b5f75f2b_ae88_b9ce_360f_813018b7842e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/middlewares/static.ts lines 292–312

export function isFileLoadingAllowed(
  config: ResolvedConfig,
  filePath: string,
): boolean {
  const { fs } = config.server

  if (!fs.strict) return true

  // NOTE: `fs.readFile('/foo.png/')` tries to load `'/foo.png'`
  // so we should check the path without trailing slash
  const filePathWithoutTrailingSlash = filePath.endsWith('/')
    ? filePath.slice(0, -1)
    : filePath
  if (config.fsDenyGlob(filePathWithoutTrailingSlash)) return false

  if (config.safeModulePaths.has(filePath)) return true

  if (fs.allow.some((uri) => isFileInTargetPath(uri, filePath))) return true

  return false
}

Domain

Subdomains

Frequently Asked Questions

What does isFileLoadingAllowed() do?
isFileLoadingAllowed() is a function in the vite codebase, defined in packages/vite/src/node/server/middlewares/static.ts.
Where is isFileLoadingAllowed() defined?
isFileLoadingAllowed() is defined in packages/vite/src/node/server/middlewares/static.ts at line 292.
What does isFileLoadingAllowed() call?
isFileLoadingAllowed() calls 1 function(s): isFileInTargetPath.
What calls isFileLoadingAllowed()?
isFileLoadingAllowed() is called by 3 function(s): checkLoadingAccess, isFileServingAllowed, loadAndTransform.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free