title: AWS API Gateway with Lambda proxy always produces base64 string response
body: <p>I'm using API Gateway Lambda proxy integration and trying to return a binary <code>application/protobuf</code> response.  No matter what I do, the response body is always a base64 encoded string</p>
  
  <ul>
  <li>I have <code>application/protobuf</code> setup as a <code>binary media types</code> in APIG</li>
  <li>My client (javascript) is sending following headers in the <code>POST</code>:
  <code>
  Accept: application/protobuf 
  Content-Type: application/protobuf
  </code></li>
  <li>My lambda is responing with <code>content-type: application/protobuf</code>, and correctly setting the <code>IsBase64Encoded</code> Lambda response to <code>true</code></li>
  </ul>
  
  <p>How do you get APIG to base64 decode the string? I swear I had this working a few months ago when I 1st tried this.</p>
  
  <p>Note: I've also tried <code>*/*</code> as a <code>binary media types</code></p>
  
  <p>Some related posts to add background:</p>
  
  <ul>
  <li><a href="https://github.com/twitchtv/twirp/issues/81" rel="noreferrer">https://github.com/twitchtv/twirp/issues/81</a></li>
  <li><a href="https://github.com/awslabs/aws-serverless-express/issues/39#issuecomment-276019222" rel="noreferrer">https://github.com/awslabs/aws-serverless-express/issues/39#issuecomment-276019222</a></li>
  </ul>
  
  <p><strong>Update:</strong></p>
  
  <p>Turns out I can only get it working if <code>binary media type</code> is set to <code>*/*</code>.  The client <code>Accept</code> header has no impact once it is set to this.</p>
  
  <p>Many bad side effects of using <code>*/*</code> because every response is attempted to get decoded (even when IsBase64Encoded is false or not set)</p>
  
  <p>I thought it wasn't decoding because Chrome network inspect tools will always show binary data as base64 encoded in the <code>Preview</code> tab.  You can see the protobuf in the <code>Response</code> tab.</p>