Skip to content

Query String encoding issues when using ALB #456

@tobyryuk

Description

@tobyryuk

When running API Gateway, query strings in the event object are automagically URL decoded but when using Application Load Balancer, they're not. This leads to a problem where the getQueryString function (here) ends up URL encoding ALB query strings twice. (more information can be found here)

Here's an example of what we get out when using these parameters ?single=value%20with%20spaces&multi[rise%20of%20planets]=hello%20world&multi[death%20of%20planets]=bye%20world running Laravel.

API Gateway
Screenshot 2019-09-16 at 15 20 48

Application Load Balancer
Screenshot 2019-09-16 at 15 20 39

From what I've found so far, there's no super clear way of figuring out if the invokation is from API Gateway or Application Load Balancer but what we could do is check the event and see if the API Gateway specific event properties are there or not and URL decode the result of the http_build_query once before returning it, if not from API Gateway. (event differences from SO)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions