API calls hidden with URL rewrites sometimes return 502

Hello, we have a new spa running on netlify, and with this one we decided to create a proxy redirect to hide our api and for CORS. The site and the redirect work mostly great, but we have had a few 502 errors returned from api calls to the proxy rewrite randomly. Can anyone check out what might be happening?

One x-nf-request-id on a 503 response captured with Logrocket: 01FXP1NDRJFDW6MFHMARG9P4MB

Redirect rule in netlify.toml (placeholder is replaced with a custom build command):

[[redirects]]
    from = "/api/*"
    to = "API_URL_PLACEHOLDER/:splat"
    force = true
    status = 200

Hey @DamageS,

This is the error we see in our logs:

read tcp 100.64.0.198:46278->172.31.0.82:9080: read: connection reset by peer

It appears to be an error coming from the destination server.