-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Can we make reverse proxy response available in templates #4420
Comments
Hmm. I think you'd be better off by responding with HTML that has JS Or, write a separate backend endpoint that renders HTML from the the JSON with an actual programming language. There's a bunch of pieces in play here that make this tricky to implement, and I'm afraid it'll add undue complexity to the system:
|
Yeah, this'll definitely require buffering the response. Maybe if it was explicitly enabled in config (up to a max size, I dunno?) that would be one easy way to do it. For example, "Enabling this option always reads the response from the backend up to a certain size and then sets these placeholders/variables, etc." |
FYI, this should be closer to being possible to implement now that we have a Parsing the response is a whole other thing though, and likely best left to plugins once #4568 is done as well. |
it seems working under v2.5.1, but how to turn it off? |
@mindon you'll need to elaborate. What's your config? What behaviour are you seeing? What does it look like when you make a request with |
remove encode zstd gzip from target server or the templates from current server deliminates the 500 error here's a simple config
|
@francislavoie a simple case is proxy target output something like "{{}}", then caddy app with templates will surely 500 error |
That seems off-topic from what this issue is about @mindon. The feature request here is about being able to write the proxy response from within a template, with |
Also sorted the func map just for kicks.
@byoungdale Please see #4871 where I've implemented this functionality. It's a little rough around the edges still, but it should work. If you want to parse JSON, simply use the |
This is in response to my question here on the community forum.
Can we add a feature where the response to a reverse proxy can be made available to or passed as argument(s) to templates?
And if the response from the 127.0.0.1:3000 application is:
Being able to do something like this:
The text was updated successfully, but these errors were encountered: