Interface: Server
The Server option changes the behavior of dev-server.
Properties
base?
optionalbase?:string
Configure the base path of the server.
Default Value
'/'
Remarks
Users can access lynx bundle through http://<host>:<port>/main.lynx.bundle by default.
If you want to access lynx bundle through http://<host>:<port>/foo/main.lynx.bundle, you can change server.base to /foo
you can refer to server.base for more information.
Example
compress?
optionalcompress?:boolean|CompressOptions
Configure whether to enable gzip compression for static assets served by the dev server or preview server.
Default Value
Remarks
See Rsbuild - server.compress for details.
Examples
To disable the gzip compression, set compress to false:
Compress if it starts with /foo
set level of zlib compression
cors?
optionalcors?:boolean|CorsOptions
Configure CORS for the dev server or preview server.
Default Value
Remarks
-
Set to an object to enable CORS with the specified options.
-
Set to
trueto enable CORS with the default options (allows all origins, not recommended). -
Set to
falseto disable CORS.
See Rsbuild - server.cors for details.
Example
headers?
optionalheaders?:Record<string,string|string[]>
Adds headers to all responses.
Default Value
Example
host?
optionalhost?:string
Lynx Default Changed
Specify the host that the Rspeedy Server listens to.
Default Value
Remarks
During rspeedy dev, if server.host is unset, the dev plugin keeps the server bound to the IPv4 wildcard address while resolving dev-server-related URLs and client host settings with a detected non-loopback IPv4 address, such as 192.168.1.50. If no eligible IPv4 address exists, it binds to the IPv6 wildcard address and uses a detected IPv6 address for URLs. It falls back to an IPv4 loopback URL when no non-loopback IP is available. If you have multiple network interfaces, set server.host explicitly to choose the desired address.
Example
Set the host to a custom value:
port?
optionalport?:number
Specify the port that the Rspeedy Server listens to.
Default Value
Rsbuild defaults this option to 3000.
Remarks
By default, the server automatically increments the port number when the configured port is occupied.
Example
Set the port to a custom value:
proxy?
optionalproxy?:ProxyConfig
Configure proxy rules for the dev server or preview server to proxy requests to the specified service.
Default Value
Example
strictPort?
optionalstrictPort?:boolean
When a port is occupied, Rspeedy will automatically increment the port number until an available port is found.
Default Value
Remarks
By default, strict port mode is disabled. Set strictPort to true and Rspeedy will throw an exception when the port is occupied.