1. Caddy version (caddy version
): v2.4.6
2. How I run Caddy:
This is all local development for testing Caddy.
a. System environment:
MacOS Big Sur
b. Command:
caddy run
c. Service/unit/compose file:
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.
d. My complete Caddyfile or JSON config:
:9000
reverse_proxy 127.0.0.1:3000 {
handle_response {
templates
try_files posts.html
file_server
}
}
3. The problem I’m having:
I have a test JSON API running on port 3000, and I am reverse proxying on port 9000. That all works fine. What I would like to do is get the response from the JSON API and use the response in a template.
So, if the API responds with:
{
"id": 1,
"title": "Post 1"
}
I would like to be able to use that value in the template. But, don’t see any reference to a response object available for templates.
4. Error messages and/or full log output:
Nothing to output because I am still trying to figure out how to get the response into the template.
5. What I already tried:
I have tried to search the internet for someone trying to do something similar, but I just can’t seem to find what I am trying to do. Or, maybe I am not understanding properly how to do what I am trying to do in Caddy.