Skip to content

Commit efee917

Browse files
authored
fix: include the protocol when creating HttpIncoming (#279)
* fix: include the protocol when creating HttpIncoming * refactor: guard against a future addition
1 parent b1d761e commit efee917

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/layout-plugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export default fp(
2727
// can add to `reply.app.params` using either of the hooks in
2828
// the lifecycle before it https://fastify.dev/docs/latest/Reference/Hooks/#hooks
2929
fastify.addHook('preHandler', async (request, reply) => {
30+
// @ts-expect-error We need the protocol in HttpIncoming https://github.com/podium-lib/utils/blob/1b636c2c8da25e59064e6051a4ae2de1d5e5b7b3/lib/http-incoming.js#L6-L11 but it's not on the raw request by default
31+
if (!request.raw.protocol) {
32+
// @ts-expect-error
33+
request.raw.protocol = request.protocol;
34+
}
3035
const incoming = new HttpIncoming(
3136
request.raw,
3237
reply.raw,

0 commit comments

Comments
 (0)