Skip to content

Commit 4c2f46e

Browse files
author
Wojciech Stachowski
committed
Allow upstream to be undici.BalancedPool, pass maxRetriesOn503 to replyOpts
1 parent bd35915 commit 4c2f46e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ be streamed directly to the destination._
124124

125125
An URL (including protocol) that represents the target server to use for proxying.
126126

127+
It can be an array of URLs, if you want to use [`undici.BalancedPool`](https://undici.nodejs.org/#/docs/api/BalancedPool) (`upstream` is compatible with [`base`](https://github.com/fastify/fastify-reply-from?tab=readme-ov-file#base) option).
128+
127129
### `prefix`
128130

129131
The prefix to mount this plugin on. All the requests to the current server starting with the given prefix will be proxied to the provided upstream.

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,10 @@ async function fastifyHttpProxy (fastify, opts) {
532532

533533
const internalRewriteLocationHeader = opts.internalRewriteLocationHeader ?? true
534534
const oldRewriteHeaders = (opts.replyOptions || {}).rewriteHeaders
535+
const maxRetriesOn503 = opts.maxRetriesOn503
535536
const replyOpts = Object.assign({}, opts.replyOptions, {
536-
rewriteHeaders
537+
rewriteHeaders,
538+
maxRetriesOn503
537539
})
538540
fromOpts.rewriteHeaders = rewriteHeaders
539541

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ declare namespace fastifyHttpProxy {
6060
) => string
6161

6262
export interface FastifyHttpProxyOptions extends FastifyReplyFromOptions {
63-
upstream: string;
63+
upstream: string | string[];
6464
prefix?: string;
6565
rewritePrefix?: string;
6666
proxyPayloads?: boolean;

0 commit comments

Comments
 (0)