@fastify/reply-from
Advanced tools
Comparing version 9.3.0 to 9.4.0
@@ -55,2 +55,3 @@ 'use strict' | ||
const req = this.request.raw | ||
const method = opts.method || req.method | ||
const onResponse = opts.onResponse | ||
@@ -131,3 +132,3 @@ const rewriteHeaders = opts.rewriteHeaders || headersNoOp | ||
// discussion: https://github.com/fastify/fastify/issues/953 | ||
if (req.method === 'GET' || req.method === 'HEAD') { | ||
if (method === 'GET' || method === 'HEAD') { | ||
// body will be populated here only if opts.body is passed. | ||
@@ -137,3 +138,3 @@ // if we are doing that with a GET or HEAD request is a programmer error | ||
if (body) { | ||
throw new Error(`Rewriting the body when doing a ${req.method} is not allowed`) | ||
throw new Error(`Rewriting the body when doing a ${method} is not allowed`) | ||
} | ||
@@ -147,3 +148,3 @@ } | ||
let requestImpl | ||
if (retryMethods.has(req.method) && !contentLength) { | ||
if (retryMethods.has(method) && !contentLength) { | ||
requestImpl = createRequestRetry(request, this, retriesCount, retryOnError, maxRetriesOn503) | ||
@@ -154,3 +155,3 @@ } else { | ||
requestImpl({ method: req.method, url, qs, headers: requestHeaders, body }, (err, res) => { | ||
requestImpl({ method, url, qs, headers: requestHeaders, body }, (err, res) => { | ||
if (err) { | ||
@@ -157,0 +158,0 @@ this.request.log.warn(err, 'response errored') |
{ | ||
"name": "@fastify/reply-from", | ||
"version": "9.3.0", | ||
"version": "9.4.0", | ||
"description": "forward your HTTP request to another server, for fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -391,2 +391,6 @@ # @fastify/reply-from | ||
#### `method` | ||
Replaces the original request method with what is specified. | ||
#### `retriesCount` | ||
@@ -393,0 +397,0 @@ |
@@ -70,2 +70,3 @@ /// <reference types="node" /> | ||
) => string; | ||
method?: HTTPMethods; | ||
} | ||
@@ -72,0 +73,0 @@ |
@@ -93,2 +93,3 @@ import replyFrom, { FastifyReplyFromOptions } from ".."; | ||
reply.from("/", { | ||
method: "POST", | ||
rewriteHeaders(headers, req) { | ||
@@ -95,0 +96,0 @@ return headers; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179397
106
5283
440
72