# ControllerOptions

**Kind:** Interface

**Source:** [`packages/common/decorators/core/controller.decorator.ts`](https://github.com/nestjs/nest/blob/master/packages/common/decorators/core/controller.decorator.ts#L16)

**Part of:** [Common](subsystem-packages-common)

Interface defining options that can be passed to `@Controller()` decorator

`ControllerOptions` defines configuration accepted by NestJS's `@Controller()` decorator. It lets a controller declare one or more route path prefixes and optionally restrict routing to specific hostnames or host-matching regular expressions.

## Properties

| Property | Type |
|---|---|
| `path` | `string | string[]` |
| `host` | `string | RegExp | Array<string | RegExp>` |

## Diagram

```mermaid
graph LR
  A["@Controller(options)"] --> B["ControllerOptions"]
  B --> C["path: string | string[]"]
  B --> D["host: string | RegExp | Array<string | RegExp>"]
  C --> E["Controller route prefixes"]
  D --> F["Host-based route matching"]
```

## Usage

```ts
import { Controller, Get } from '@nestjs/common';
import type { ControllerOptions } from '@nestjs/common';

const controllerOptions: ControllerOptions = {
  path: ['users', 'members'],
  host: ['api.example.com', /^admin\./],
};

@Controller(controllerOptions)
export class UsersController {
  @Get()
  findAll() {
    return [];
  }
}
```

## AI Coding Instructions

- Use `path` to define a single controller prefix or multiple equivalent prefixes.
- Use `host` only when the controller should respond to specific domains or subdomains.
- Prefer `RegExp` host rules for pattern-based subdomain matching, such as `/^admin\./`.
- Ensure host-based routing is supported by the active HTTP adapter and deployment proxy configuration.
- Keep controller options focused on routing configuration; define request handling logic in controller methods.
