Search code examples
amazon-web-servicesamazon-s3gzipclever-cloud

Clever Cloud (S3 Bucket) can't serve compressed gzip files


I'm using Clever Cloud with static hosting and I want to serve compressed files. I used gzipper to generate gzipped files

"compress:gzip": "gzipper compress ./dist/apps/site ./dist/apps/site "

The dist folder contains both normal and compressed files, I tried to get into the S3 bucket config with the CLI and added Content-Length as an allowed header in the CORS configuration but that doesn't seem to work

CORS config :

<CORSConfiguration>
  <CORSRule>
    <AllowedOrigin>console.clever-cloud.com</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
    <AllowedHeader>Content-Length</AllowedHeader>
    <ExposeHeader>ETag</ExposeHeader>
  </CORSRule>
  <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>Authorization</AllowedHeader>    
        <AllowedHeader>Content-Length</AllowedHeader>
  </CORSRule>
</CORSConfiguration>

Solution

  • I think you should expose the header Content-Length instead of allowing it. You should also expose Content-Encoding to tell the client that the server is sending a gzipped response.

    • AllowedHeader is for request headers.
    • ExposeHeader is for response headers.