Can be used to configure the server (Fastify).

Note that the HTTPS are only read at runtime via environment variables. The HTTPS key can be set via the SERVER_KEY_PATH variable, and the certificate can be set via the SERVER_CERT_PATH variable.

The server tries to read the HOST and PORT environment variables to configure the listen target. If the environment variable SERVER_SOCKET is set, it will take precedence over HOST and PORT. In the case, none of the above (HOST, PORT, SERVER_SOCKET) variables are present it will use the Astro server options.

interface ServerOptions {
    accessLogging: boolean;
    connectionTimeout: number;
    gracefulTimeout: number;
    http2: boolean;
    keepAliveTimeout: number;
    logLevel: Level;
    requestIdHeader: string | false;
    trustProxy: TrustedProxy;
}

Properties

accessLogging: boolean

Enables or disables request logging.

Environment variable: SERVER_ACCESS_LOGGING Environment value: "1" (true), "0" (false)

Default

true
connectionTimeout: number

Defines the server timeout in milliseconds. See the Node.js documentation for more details: https://nodejs.org/api/http.html#http_server_timeout

Environment variable: SERVER_CONNECTION_TIMEOUT Environment value:

Default

0
gracefulTimeout: number

The time in milliseconds to wait for the server to gracefully close before forcefully shutting down.

Environment variable: SERVER_GRACEFUL_TIMEOUT Environment value:

Default

5000
http2: boolean

If true an HTTP/2 server will be created instead of the HTTP/1.1 one.

Environment variable: SERVER_HTTP2 Environment value: "1" (true), "0" (false)

Default

false
keepAliveTimeout: number

Defines the server keep-alive timeout in milliseconds. See the Node.js documentation for more details: https://nodejs.org/api/http.html#http_server_keepalivetimeout

Environment variable: SERVER_KEEP_ALIVE_TIMEOUT Environment value:

Default

72000
logLevel: Level

Defines the log level the server should use. Note that this only affects the server, not Astro itself.

Environment variable: SERVER_LOG_LEVEL Environment value: Level

Default

info
requestIdHeader: string | false

The header name that should be used to set the request ID. Fore more details see Fastify's documentation: https://fastify.dev/docs/latest/Reference/Logging/#logging-request-id

Environment variable: SERVER_REQUEST_ID_HEADER Environment value:

Default

"request-id"
trustProxy: TrustedProxy

Lets the server know that it's behind a proxy and should trust the "X-Forwarded-*" headers. For more details see Fastify's documentation: https://fastify.dev/docs/latest/Reference/Server/#trustproxy

Environment variable: SERVER_TRUST_PROXY Environment value: "1" (true), "0" (false),