Prerequisites
Fastify version
all
Plugin version
2.0.2
Node.js version
14
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
not applicable
Description
When using Lambda as a target for an ALB, the queryStringParameters in the Lambda event is not decoded, unlike with API Gateway. This isn't really well documented, but there's a small section in the docs that mentions this (not really sure why they put it under the "multi-value headers" section, but it applies to the queryStringParameters and multiValueQueryStringParameters properties):
If the query parameters are URL-encoded, the load balancer does not decode them. You must decode them in your Lambda function.
Steps to Reproduce
This test fails:
test('GET with encoded query values', async (t) => {
t.plan(1)
const app = fastify()
app.get('/test', async (request, reply) => {
reply.send(request.query)
})
const proxy = awsLambdaFastify(app)
const ret = await proxy({
requestContext: {
elb: {
targetGroupArn: 'xxx'
}
},
httpMethod: 'GET',
path: '/test',
queryStringParameters: {
q: 'foo%3Fbar'
}
}))
t.equal(ret.body, '{"q":"foo?bar"}')
})
Expected Behavior
When the Lambda is invoked by ALB (detectable by presence of requestContext.elb object on event), the values for queryStringParameter and multiValueQueryStringParameters should be decoded before being passed to fastify.
Prerequisites
Fastify version
all
Plugin version
2.0.2
Node.js version
14
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
not applicable
Description
When using Lambda as a target for an ALB, the
queryStringParametersin the Lambda event is not decoded, unlike with API Gateway. This isn't really well documented, but there's a small section in the docs that mentions this (not really sure why they put it under the "multi-value headers" section, but it applies to thequeryStringParametersandmultiValueQueryStringParametersproperties):Steps to Reproduce
This test fails:
Expected Behavior
When the Lambda is invoked by ALB (detectable by presence of requestContext.elb object on event), the values for
queryStringParameterandmultiValueQueryStringParametersshould be decoded before being passed to fastify.