I was facing similar issues where every proxied request took 5 seconds or more with a setup something like this:
"proxy": [
{
"context": [
"/api",
],
"target": "http://my-backend-server.local:1234",
"secure": false
}
]
And in the hosts file:
127.0.0.1 my-backend-server.local
127.0.0.1 some-other-hostname.local
127.0.0.1 a-few-more-of-these.local
When I changed the proxy to point to the IPv6 loopback address the problem went away. So like this:
"proxy": [
{
"context": [
"/api",
],
"target": "http://[::1]:1234",
"secure": false
}
]
To be able to use the actual hostname in the proxy configuration instead of the loopback address, I edited my hosts file to contain all hostname entries on a single line and point them to both IPv4 and IPv6 loopback addresses. So like this:
127.0.0.1 my-backend-server.local some-other-hostname.local a-few-more-of-these.local
::1 my-backend-server.local some-other-hostname.local a-few-more-of-these.local
Now the latency is gone and it works as expected.