Skip to content

StaticServeOptions

Defined in: src/util/types.ts:863

T extends Record<string, any>

Property Type Description Defined in

dotfiles?

"ignore" | "allow" | "deny"

How to treat dotfiles (files starting with .) ‘allow’: Serve them ‘deny’: Return 403 ‘ignore’: Return 404

Default

'ignore'

src/util/types.ts:894

etag?

boolean

Enable ETags for static files.

src/util/types.ts:911

exclude?

(string | RegExp)[]

Regex or glob patterns to exclude

src/util/types.ts:898

extensions?

string[]

Try to append these extensions to the path if the file is not found. e.g. [‘html’, ‘htm’]

src/util/types.ts:903

hooks?

StaticServeHooks<T>

Hooks to intercept requests/responses.

src/util/types.ts:886

immutable?

boolean

Whether the file is immutable. maxAge must be set to a value > 0 for this to have any effect.

src/util/types.ts:920

index?

string | string[]

Index file(s) to look for when a directory is requested.

Default

['index.html', 'index.htm']

src/util/types.ts:882

listDirectory?

boolean

Whether to list directory contents if no index file is found.

Security Note: Directory listing is disabled by default to prevent information disclosure. Enable this only if you specifically need it and understand the security implications.

Default

false

src/util/types.ts:877

maxAge?

number

Maximum age for the cache.

src/util/types.ts:915

openapi?

MethodAPISpec

OpenAPI specification for the static route.

src/util/types.ts:907

root?

string

Root directory to serve files from. Can be an absolute path or relative to the CWD.

src/util/types.ts:868

useCache?

boolean

Whether to use the cache.

Default

true

src/util/types.ts:925