ERR_HTTP2_PROTOCOL_ERROR when Accessing API Endpoint on Netlify Deployed Site

  • Symptom: The error message ERR_HTTP2_PROTOCOL_ERROR is displayed when attempting to access a specific API endpoint on my Netlify deployed site.
  • Context: The API endpoint in question is designed to return image data. The endpoint works perfectly in local development environments and during manual testing, indicating that the underlying code is sound.
  • Headers: The request headers, including User-Agent, Accept, and others, appear to be correctly configured and consistent with accepted standards.
  • Response Headers: I have reviewed and set relevant response headers like Access-Control-Allow-Origin and Cache-Control, ensuring compatibility with HTTP/2.
  • Debugging Attempts: I have taken several troubleshooting steps, including inspecting logs, verifying SSL/TLS configuration, reviewing Netlify settings, and confirming the correctness of the API endpoint URL.
  • Testing: The API request was tested using various tools, including Postman, to rule out client-related issues.
  • Other Observations: The logs on the server function indicate that there are no server errors and the image is constructed properly. The return Image buffer is exactly the same as the one in my local environment.
    I have attached the failing endpoint (which should return an image) and additionally another endpoint that works just fine (that just returns a json object).

Despite these efforts, the issue persists, leading me to believe that it might be related to the server or deployment configuration on the Netlify platform. I have researched and tried potential solutions without success.

I am seeking assistance to diagnose and resolve this issue, as it is critical to the proper functioning of my site’s API interactions. Any guidance, insights, or support you can provide would be greatly appreciated.

Thank you for your attention to this matter.


Hi @charliemike3124,

Thank you for the detailed post. This looks like something wrong on our end. I’ve asked the devs to investigate further. We’ll let you know once we have more info.

1 Like


Please let me know if there any other information you need to troubleshoot this issue.

One thing that might be helpful is this: Can you tell us anything more about the workflow in that function? Is it custom code (or maybe instead auto-built from our next-runtime?)

It is custom code for a GET endpoint that does the following:

  • Fetches an image from a firebase bucket.
  • Gets the images Base64 string.
  • Sets Content-Type, Content-Length and Cache-Control headers.
  • returns the image as a Buffer.

I also have a logs right before the return statement to ensure that all of the steps above are done correctly without erroring and everything seems to log with the correct values (The Base64 string, the image format and the Buffer).

As discussed with the devs, you should not be setting the content-length yourself. Can you check if not setting that fixes it for you?