Complicated redirect from Netlify Function with parameters and wildcard

Hi! I am having trouble setting up my redirect. I have an oauth link on my site that takes the user to Stripe, which redirects them to my site and has varying parameters depending on what information is filled out on Stripe.

I do not care about passing the parameters through to the redirect because the netlify function they are first directed to saves all of that info to my database.
The from URL looks like:


There may be more parameters than scope and code. I am not sure what they will be, but I don’t need to pass them to the to redirect so I would like to use a wildcard.

The to URL looks like https://localhost:8888/provider-dashboard

My netlify.toml looks like this (the first redirect works fine):

# example netlify.toml
  command = "yarn build"
  functions = "functions"
  publish = "public"

## Uncomment to use this redirect for Single Page Applications like create-react-app. 
## Not needed for static site generators.
  from = "/room/*"
  to = "/room"
  status = 200

  from = "/.netlify/functions/authorize-connect-account*"
  to = "/provider-dashboard"
  status = 200

I have tried using query = {state = ":state"},

from = "/.netlify/functions/*"
to= "/provider-dashboard:splat"

and have looked at
I think the problem might be that I either need to include every query parameter or that the wildcard is not after a /.

Whatever change I make, I receive the following error Invalid /.netlify path in redirect source

Any help is greatly appreciated!

I created a small demo site and I’ve included what my _redirects rule is.

/authorize-connect-account state=:state /provider-dashboard?state=:state 200!

In this example: /authorize-connect-account?state=101 will proxy (200!) redirect to /provider-dashboard?state=101

It strips any additional query parameters for you.

I hope this helps! Redirects are pretty powerful :+1:.

Thank you for the reply!
Apparently this was a bit trickier than I had originally thought. My understanding is now that if I had used the 200 redirect, it wouldn’t have invoked my netlify function correctly. So, what I did was added this code to my netlify function and it redirects perfectly while invoking my function to add the info passed to my url into my database.

return {
            statusCode: 302,
            body: JSON.stringify({ msg: response }),
            headers: {
                location: "/provider-dashboard"

Snazzy, I like it! :partying_face: