Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect rewrites inconsistent between netlify dev and production #1605

Closed
parkan opened this issue Nov 30, 2020 · 3 comments · Fixed by #2017
Closed

Redirect rewrites inconsistent between netlify dev and production #1605

parkan opened this issue Nov 30, 2020 · 3 comments · Fixed by #2017
Labels
area: command: dev area: redirects type: bug code to address defects in shipped code

Comments

@parkan
Copy link

parkan commented Nov 30, 2020

Describe the bug

Referencing this netlify community post

Redirects of the form:

/echo/:msg /.netlify/functions/echo?msg=:msg 200

will populate the queryString parameter msg in netlify dev, however they will not in production. While I prefer the netlify dev behavior, I was advised to open a bug here to change it for consistency.

To Reproduce

Set a redirect that uses parameter matching and rewrites them into the target URL. The value will be copied to the target query parameter.

Configuration
N/A

Expected behavior

Nothing should happen (value in target URL should be ignored)

Additional context

Of course, I would vastly prefer that one of these two things happened:

  • The current netlify dev behavior worked in production
  • (even better) any redirects containing path parameters populated the pathParameters property of the APIGatewayEvent as they do on AWS API Gateway

However, I was advised by the platform team that this probably won't happen, so I will need to add the path expressions to each function, which is brittle and not DRY, but nonetheless the CLI behavior should match production.

My guess is that whatever netlify dev uses as the proxy server does this automagically.

@parkan parkan added the type: bug code to address defects in shipped code label Nov 30, 2020
@robbiehudson
Copy link

Thanks for raising this bug @parkan. This just bit us when we deployed a new function to production. Very unexpected that the dev behaviour doesn't match production (and of course, trying to debug this was hard!).

@parkan
Copy link
Author

parkan commented Dec 15, 2020

@robbiehudson this definitely took a second to track down, I thought I was losing my mind! this is how I ended up tackling the issue (using pathParameters rather than queryParameters), using the excellent lambda-middleware: https://gist.github.com/parkan/f0b95f343e18aaadd1bb93b4ca67806d

@robbiehudson
Copy link

@parkan this is great, thank you (and much better than my String.split hack that I used to get it working).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: command: dev area: redirects type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants