> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# dev.server

- **Type:** `Object`
- **Default:** `{}`

The config of DevServer can be modified through `dev.server`.

### compress

- **Type:** `boolean`
- **Default:** `true`

Whether to enable gzip compression for served static assets.

If you want to disable the gzip compression, you can set `compress` to `false`:

```ts
export default {
  dev: {
    server: {
      compress: false,
    },
  },
};
```

For more details, please refer to the [Rsbuild - server.compress](https://v2.rsbuild.rs/config/server/compress) documentation.

### headers

- **Type:** `Record<string, string>`
- **Default:** `undefined`

Adds headers to all responses.

```js
export default {
  dev: {
    server: {
      headers: {
        'X-Custom-Foo': 'bar',
      },
    },
  },
};
```

For more details, please refer to the [Rsbuild - server.headers](https://v2.rsbuild.rs/config/server/headers) documentation.

### historyApiFallback

- **Type:** `boolean | ConnectHistoryApiFallbackOptions`
- **Default:** `false`

The index.html page will likely have to be served in place of any 404 responses. Enable `dev.server.historyApiFallback` by setting it to `true`:

```js
export default {
  dev: {
    server: {
      historyApiFallback: true,
    },
  },
};
```

For more configuration options, please refer to the [Rsbuild - server.historyApiFallback](https://v2.rsbuild.rs/config/server/history-api-fallback) documentation.

### watch

- **Type:** `boolean`
- **Default:** `true`

Whether to watch files change in directories such as `mock/`, `server/`, `api/`.

For more details, please refer to the [Rsbuild - dev.watchFiles](https://v2.rsbuild.rs/config/dev/watch-files) documentation.

### cors

- **Type:** `boolean | import('cors').CorsOptions`

Configure CORS (Cross-Origin Resource Sharing) for the development server.

The default configuration for `cors` in Modern.js follows Rsbuild's defaults:

```ts
const defaultAllowedOrigins =
  /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;

const defaultOptions = {
  // Default allowed:
  // - localhost
  // - 127.0.0.1
  // - [::1]
  origin: defaultAllowedOrigins,
};
```

For more configuration options and detailed usage, please refer to the [Rsbuild - server.cors](https://v2.rsbuild.rs/config/server/cors) documentation.

### proxy

- **Type:** `ProxyOptions[] | Record<string, string | ProxyOptions>`
- **Default:** `undefined`

Configure proxy rules for the dev server, and forward requests to the specified service.

```js
export default {
  dev: {
    server: {
      proxy: {
        // http://localhost:8080/api -> https://example.com/api
        // http://localhost:8080/api/foo -> https://example.com/api/foo
        '/api': 'https://example.com',
      },
    },
  },
};
```

:::tip
This option is the same as Rsbuild's `server.proxy` option, see [Rsbuild - server.proxy](https://v2.rsbuild.rs/config/server/proxy) for detailed usage.
:::
