Configure CORS for the dev server. Uses https://github.com/expressjs/cors.
When enabling this option, we recommend setting a specific value
rather than true to avoid exposing the source code to untrusted origins.
Set to true to allow all methods from any origin, or configure separately
using an object.
Specify server response headers.
OptionalhostSpecify which IP addresses the server should listen on. Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
OptionalhttpsEnable TLS + HTTP/2. Note: this downgrades to TLS only when the proxy option is also used.
Open browser window on startup
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.
OptionalproxyConfigure custom proxy rules for the dev server. Expects an object
of { key: options } pairs.
Uses http-proxy-3.
Full options here.
Example vite.config.js:
module.exports = {
proxy: {
// string shorthand: /foo -> http://localhost:4567/foo
'/foo': 'http://localhost:4567',
// with options
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
rewrite: path => path.replace(/^/api/, '')
}
}
}
If enabled, vite will exit if specified port is already in use
The hostnames that Vite is allowed to respond to.
localhostand subdomains under.localhostand all IP addresses are allowed by default. When using HTTPS, this check is skipped.If a string starts with
., it will allow that hostname without the.and all subdomains under the hostname. For example,.example.comwill allowexample.com,foo.example.com, andfoo.bar.example.com.If set to
true, the server is allowed to respond to requests for any hosts. This is not recommended as it will be vulnerable to DNS rebinding attacks.