queryStringParameters not working with redirect on production

rewrites to functions work differently than rewrites to other paths

Well that’s interesting. That must be the source of my problem.

They suggested that you could accomplish what you want by grabbing the incoming path…directly in your function using event.path and then parsing the param you’re interested in within your function.

That doesn’t work. Or maybe I’m misunderstanding the suggestion?

Let’s say I have the following redirect:

/thing /.netlify/functions/thing?foo=bar 200

If I do a GET to /thing that results in the invoked function’s event.path being /thing, which as I type that I guess makes sense in the context of function calls. Given that case, however, there are no query parameters present and it appears impossible for a function call to know about its /.netlify/functions/path along with any query params that might be present, unless you do a GET to it directly.

So—and I’m writing out loud here—it sounds like my expectation is completely wrong. Given the redirect above, I would expect a GET to /thing to proxy a call to the netlify function URL, which would result in the function having even.path be /.netlify/functions/thing?foo=bar, which I would then be able to parse. But that’s not how it’s working. The location that is being proxied to—the /.netlify/... url—is completely hidden from the invoked function.

Thus, from what I can tell in the implementation, it seems impossible to add query string parameters to a redirect for a function call, i.e. even given a hard-coded redirect of

/path /.netlify/functions/path?foo=bar 200

It’s impossible for the invoked function to know anything about foo=bar.