How to get the URL requested from API Gateway / Lambda?

I’ve been deploying more and more of my architecture onto Serverless / AWS Lambda and am loving it so far. However I have just run into an edge case using Node / Express.

Lets say I receive a request via API Gateway:

my.lambda/?foo=bar&marco=polo

In my express app I’m grabbing the full path via req.originalUrl

On my local server using sls offline, the originalUrl comes out intact as entered in the address bar.

But for some reason when I deploy live the express app is receiving the originalUrl with parameters in a different order. e.g. it might come out as my.lambda/?marco=polo&foo=bar

…Almost like API Gateway has massaged the URL, to perform some validation etc.

Am I imagining this? Or is this a known “feature” of API Gateway?

I need the original URL, un-massaged - is there any way to get this?

Consider this course: First, in the Lambda, dump the incoming event using a simple console.log statement. Then after a test api call, use Cloudwatch logs to inspect the log file which will contain the full event object. I’m not sure what format of APIGW-LAMBDA integration you are using, but chances are the Request Context (or similar) prop might tell you what you need to know.