Skip to content
On this page

Beyond Fast

ViteConf 2023

Watch the replay!

Preview Options

Specify which IP addresses the server should listen on. Set this to or true to listen on all addresses, including LAN and public addresses.

This can be set via the CLI using --host or --host.


There are cases when other servers might respond instead of Vite. See for more details.


  • Type: number
  • Default: 4173

Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on.


export default defineConfig({
  server: {
    port: 3030,
  preview: {
    port: 8080,


Set to true to exit if port is already in use, instead of automatically trying the next available port.


Enable TLS + HTTP/2. Note this downgrades to TLS only when the server.proxy option is also used.

The value can also be an options object passed to https.createServer().

Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname. If you want to open the server in a specific browser you like, you can set the env process.env.BROWSER (e.g. firefox). You can also set process.env.BROWSER_ARGS to pass additional arguments (e.g. --incognito).

BROWSER and BROWSER_ARGS are also special environment variables you can set in the .env file to configure it. See the open package for more details.


  • Type: Record<string, string | ProxyOptions>
  • Default: server.proxy

Configure custom proxy rules for the preview server. Expects an object of { key: options } pairs. If the key starts with ^, it will be interpreted as a RegExp. The configure option can be used to access the proxy instance.

Uses http-proxy. Full options here.


Configure CORS for the preview server. This is enabled by default and allows any origin. Pass an options object to fine tune the behavior or false to disable.


  • Type: OutgoingHttpHeaders

Specify server response headers.

Released under the MIT License. (aac695e9)