fastify-http-proxy
fastify-http-proxy copied to clipboard
Allow for dynamic websocket upstreams with `replyOptions.getUpstream`
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
It would be nice to allow for dynamic upstreams when forwarding on websocket upgraded requests much in the same way that you can specify a getUpstream
function to your replyOptions
to pass some logic to determine an http upstream. However, leaving the wsUpstream
property as an empty string results in the following error:
Error: upstream must be specified
It would be nice if this could be avoided when a getUpstream
is supplied for an empty wsUpstream
option.
Motivation
No response
Example
For example, it would be nice to register a websocket proxying mechanism like so
fastify.register(require('@fastify/http-proxy'), {
websocket: true,
wsUpstream: '',
replyOptions: {
getUpstream: function (req) {
// some logic to determine the wsUpstream
}
}
})