staticFiles

View Source

Summary

Creates a middleware that serves static files from the filesystem.

Uses the URL pathname to resolve files, removing the leading slash to make it a relative path. The middleware always falls through to the handler if the file is not found or an error occurs.

Signature

function staticFiles(root: string, options: StaticFilesOptions): Middleware;

Params

root

The root directory to serve files from (absolute or relative to cwd)

options

Configuration for file responses

Returns

The static files middleware