Redirect/Rewrite to function seems broken?

Hey @j-o-sh,

I absolutely get it now. I was jumping a few steps ahead! This topic explains some of your observations from earlier in the week.

We’re trying to pass a static query parameter to a function via a rewrite without having to specify it in the original path.

I’ve racked by brain and played with the demo site I set up before conceding and consulting our platform team. Turns out, it’s a known use case which we don’t currently support live. However, we strive to align this with Netlify Dev so, perhaps in future, we’ll see this working.

I understand that this perhaps isn’t the news you were expecting. However, there are a few workarounds which, I hope, allow you to perform what you’d like to achieve.

Firstly, the rule /wishes.mine /.netlify/functions/wishes_render?key=testkey 301! does pass the query string through (note the 301). So, your desired behaviour does work for redirects but not at present for rewrites. If this is a suitable workaround then great!

Depending on what’s important to you, and the significance/secrecy of the key, you may instead want to add the key as an environment variable within the Netlify UI and pass it to the function directly, thus hiding it.