Skip to main content

title: InterceptorServer | @zimic/interceptor sidebar_label: InterceptorServer slug: /interceptor/api/interceptor-server

InterceptorServer

A server to intercept and handle requests. It is used in combination with remote interceptors.

Related:

server.hostname

The hostname of the server. It can be reassigned to a new value if the server is not running.

Type: string

server.port

The port of the server. It can be reassigned to a new value if the server is not running.

Type: number | undefined

server.logUnhandledRequests

Whether to log warnings about unhandled requests to the console. It can be reassigned to a new value.

Type: boolean (default: true)

server.tokensDirectory

The directory where the authorized interceptor authentication tokens are saved. If provided, only remote interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor server publicly. For local development and testing, though, a tokens directory is optional.

Type: string | undefined

Related:

server.isRunning

Whether the server is running.

Type: boolean (readonly)

server.start()

Starts the server. It will automatically stop if a process exit event is detected, such as SIGINT, SIGTERM, or an uncaught exception.

await server.start();

Returns: Promise<void>

server.stop()

Stops the server.

await server.stop();

Returns: Promise<void>