Skip to main content

bud.proxy: options

You can pass a function to bud.proxy to manipulate all options. You must return them or the options will not be set!

bud.config.ts
bud.proxy((options = {}) => {
options.target = 'https://example.test'
return options
})

You can also pass an object to bud.proxy to set options. This will not overwrite unspecified defaults or options set elsewhere:

bud.config.ts
bud.proxy({
target: 'https://example.test',
changeOrigin: false,
})

Options can be specified as a second parameter (instead of the URL replacement array):

bud.config.ts
bud.proxy('https://example.test', {
changeOrigin: false,
})

Available options

See documentation of available options in the proxy middleware's README.

Below are the available options and their default values:

OptionTypeDefaultDescription
agentAgentundefinedThe agent used for proxying
authstringundefinedBasic authentication i.e. 'user:password' to compute an Authorization header
autoRewritebooleantrueAutomatically rewrite the location host/port
bufferStreamundefinedA writable stream to serve as the response buffer
changeOriginbooleantrueChanges the origin of the host header to the target URL
cookieDomainRewriteRecord<string, string>key is host set by bud.serve, value is the target hostRewrite cookie domains
cookiePathRewriteRecord<string, string>undefinedRewrite cookie paths
ejectPluginsbooleanundefinedEjects all plugins
followRedirectsbooleanfalseFollow HTTP 3xx responses as redirects
forwardURLundefinedThe URL to forward to.
headersRecord<string, string>undefinedAdditional headers
hostRewritestringSet by bud.serveRewrites the location hostname on (301 / 302 / 307 / 308) redirects
ignorePathbooleanundefinedIgnore the proxy path of the incoming request
localAddressstringundefinedLocal interface string to bind for outgoing connections
loggerConsolebud.js implementationA logger object. Needs to implement warn, info, and error.
onProxy Eventsbud.js implementationEvent listeners. Note that setting this option will unset onProxyReq and onProxyRes
onProxyReqProxyReqCallbackbud.js implementationCallback function to modify the proxy request
onProxyResProxyResCallbackbud.js implementationCallback function to modify the proxy response
pathFilterArray<string>['!/bud/**']Filters the paths to proxy
pathRewriteRecord<string, string>undefinedRewrites the location path on (301 / 302 / 307 / 308) redirects
pluginsArray<(proxyServer: HttpProxy, options: ServerOptions) => void>undefinedArray of plugins to apply to the proxy server
prependPathbooleanundefinedPrepend the target's path to the proxy path
preserveHeaderKeyCasebooleanundefinedPreserve the case of response header keys
protocolRewritehttp | httpshttps if the protocol of the URL set by bud.serve resolved to https:Rewrites the location protocol on (301 / 302 / 307 / 308) redirects
proxyTimeoutnumberundefinedSpecifies the number of milliseconds before the proxy times out
replacementsArray<[string, string]>A tuple with the target origin paired with the dev server originReplaces dev server url with proxy url in the response body. This will never be called if on or onProxyRequest is overridden
routerRecord<string, ProxyTargetUrl | ProxyTarget>undefinedA map of regular expressions (string) to proxy options
securebooleanfalseVerify that connection is secure
selfHandleResponsebooleantrueSelf handle the response. If this is set to true (default) then the supplied onProxyRes must return a response
sslHttpsServerOptionsundefinedSSL certificate options
targetURLhttp://0.0.0.0The target URL
timeoutnumberundefinedSpecifies the number of milliseconds before the proxy response times out
toProxybooleantrueProxy to another server
xfwdbooleanundefinedAdds x-forward headers
wsbooleanundefinedProxy websockets