Interface ServeStaticConfig

Static contents service configuration.

Hierarchy

  • ServeStaticConfig

Properties

acceptRanges?: boolean

Whether ranged requests accepted.

Disabling this will not send Accept-Ranges and ignore the contents of the Range request header.

Default

true

cacheControl?: boolean

Whether to set Cache-Control response header.

Disabling this will ignore the immutable and maxAge options.

Default

true

dotfiles?: "ignore" | "allow" | "deny"

How "dotfiles" are treated when encountered.

A dotfile is a file or directory that begins with a dot (.).

This check is done on the path itself without checking if the path actually exists on the disk. If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").

Possible values:

  • 'allow' No special treatment for dotfiles
  • 'deny' Send a 403 for any request for a dotfile
  • 'ignore' (the default) Pretend like the dotfile does not exist and call next()

Default

ignore

etag?: boolean

Whether to generate ETag response headers.

Default

true

extensions?: false | string[]

File extension fallbacks.

When set, if a file is not found, the given extensions will be added to the file name and search for.

The first that exists will be served. Example: ['html', 'htm'].

Default

false.

immutable?: boolean

Whether to add the immutable directive in the Cache-Control response header.

If enabled, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed.

index?: string | boolean | string[]

Whether to send index.html file in response to a request on a directory.

Possible values:

  • true - to send index.html files.
  • false - to disable directory index.
  • string or array of strings containing index file names.

Default

true.

lastModified?: boolean

Whether to send a Last-Modified header.

Uses the file system's last modified value.

Default

true

maxAge?: string | number

Provide a max-age in milliseconds for http caching.

This can also be a string accepted by the ms module.

Default

0

redirect?: boolean

Redirect to trailing / when the pathname is a dir.

Default

true

Generated using TypeDoc