server.proxy
- Type:
- Default:
undefined
Configure proxy rules for the dev server or preview server, and forward requests to the specified service.
Proxy options
This feature is powered by http-proxy-middleware. You can use all options provided by http-proxy-middleware, plus the extra bypass option from Rsbuild.
Rsbuild sets changeOrigin to true by default for every proxy rule. Other proxy options follow the defaults of http-proxy-middleware. Set changeOrigin: false to override it.
Example
Basic usage
A request to /api/users will now proxy the request to https://example.com/api/users.
You can also proxy to a local service:
Path rewrite
Use pathRewrite to rewrite request paths. For example, rewrite /foo to /bar:
Proxy WebSocket
To proxy WebSocket requests, set ws to true:
Path filter
pathFilter is used to select which requests should be proxied. The path used for matching is the request URL pathname.
For example, proxy requests under /auth and /api to the target service:
Extra options
bypass
- Type:
In some cases, you may not want to proxy every request. Use the bypass function to skip the proxy.
Inside the function, you have access to the request, response, and proxy options.
- Return
nullorundefinedto continue processing the request with proxy. - Return
trueto skip the proxy and continue processing the request. - Return
falseto produce a 404 error for the request. - Return a specific path to replace the original request path.
- Return a Promise to handle the request asynchronously.
For example, you may want to serve HTML for browser requests, but keep proxying API requests:

