serverless-apigateway-service-proxy icon indicating copy to clipboard operation
serverless-apigateway-service-proxy copied to clipboard

s3 is not proxied as expected

Open michal1106 opened this issue 3 years ago • 1 comments

We are trying to use serverless-apigateway-service-proxy to hook the s3 to api gateway (and in turn to our website)

But something doesn’t seem to work properly (in S3 => API Gateway part)

  • Image fails to be rendered by the browser from ApiGateway while it is rendered successfully from s3 url - see links to both images below and try to open them in browser -- https://y5f4ktp7lk.execute-api.us-east-1.amazonaws.com/dev/crs/Scorm1.2_HTML5/assets/toc/tocIcons/searchBtnNormal.png -- https://c3-lat-crs-dev.s3.amazonaws.com/Scorm1.2_HTML5/assets/toc/tocIcons/searchBtnNormal.png

  • ApiGateway ignores Range header ("Range: bytes=0-") in request - it returns 200 instead of returning 206 and (might missing additional headers - we tried to tweak the ApiGateway from the AWS Console to return 206 and still the video failed to play through ApiGateway)

is there an easy way to solve it? I assume this plugin would just proxy the s3 and return whatever status-code and headers the s3 returns - is there a way to achieve this?

Thanks, Michal

michal1106 avatar Dec 19 '22 16:12 michal1106

to fix images I found that binaryMediaTypes need to be set with */* and this can be achieved in serverless by adding

#provider.apiGateway.binaryMediaTypes
provider:
  apiGateway:
    binaryMediaTypes: "*/*"

understood this from the file below that in turn is called by this plugin: https://github.com/serverless/serverless/blob/main/lib/plugins/aws/package/compile/events/api-gateway/lib/rest-api.js#8,21

michal1106 avatar Jan 02 '23 15:01 michal1106