Skip to content

Commit

Permalink
feat: add support for request body
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <[email protected]>
  • Loading branch information
mcansh committed Aug 25, 2021
1 parent 928cacc commit 481013d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Headers,
} from "@remix-run/node";
import { FastifyReply, FastifyRequest } from "fastify";
import { PassThrough } from "node:stream";

/**
* A function that returns the value to use as `context` in route `loader` and
Expand Down Expand Up @@ -79,9 +80,9 @@ function createRemixRequest(request: FastifyRequest): Request {
headers: createRemixHeaders(request.headers),
};

// if (request.method !== "GET" && request.method !== "HEAD") {
// init.body =
// }
if (request.method !== "GET" && request.method !== "HEAD") {
init.body = request.raw.pipe(new PassThrough({ highWaterMark: 16384 }));
}

return new Request(url.toString(), init);
}

0 comments on commit 481013d

Please sign in to comment.