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

Option to enable fall-through on 404 error #1415

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aral
Copy link

@aral aral commented Jan 26, 2020

Use case:

  • I’m proxying an app (Hugo)
  • If a URL does not exist there, I want to serve it from an older version of the site

I’ve modified http-proxy-middleware to enable it to fall-through to the middleware chain (see WIP PR, which depends on this one) when it encounters a 404 but without this PR, node-http-proxy already writes out the headers and so we cannot serve the fallback content.

Further context: chimurai/http-proxy-middleware#248

Summary of merge request

  • Add fallthrough option to the context. If present, 404 responses from the target will not be handled by node-http-proxy so that they can fall through to the middleware chain by the consumer.

@hpl002
Copy link

hpl002 commented Jan 6, 2021

+1

Any momentum on this PR? Would be great to have this merged

@aral
Copy link
Author

aral commented Jan 6, 2021

Just a quick note that I fell down quite a black hole with this and ended up not implementing proxy fallbacks in my project after all. It would be worth weighing the additional complexity against the gains and considering if you can implement what you want to achieve via other methods. Not saying it’s not a legitimate use case, just that it’s not trivial to implement and this PR alone will not achieve it.

@hpl002
Copy link

hpl002 commented Jan 6, 2021

That is true. There is a likely a reason for them not implementing it from the start.

Will see if i can resolve this using other methods.

Thanks for your quick reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants