How to set up custom response headers in AWS S3

I want to send my application offline, and I want to register a service worker. My files are hosted in AWS S3, and I created worker.js in the root of my bucket. I may need to return the "Service-Worker-Allowed" custom header in response from AWS S3 for worker.js Currently, custom headers require x-amz-meta headers, which I cannot use. Do I need to add this header using Cloudfront or Cloudfare? Or any other suggestions?

+4
source share
3 answers

You cannot configure custom response headers using s3 or the cloud interface.

You have 2 possible workarounds when using AWS.

  • Proxy your requests. That is, using nginx / haproxy running on ec2
  • Use lambda@edge.

2, lambda@edge . - node. lambda @edge javascript-. , HTTP- HTTP . . . https://medium.com/@tom.cook/edge-lambda-cloudfront-custom-headers-3d134a2c18a2 , .

+4

. S3 x-amz-meta .

+2

In AWS S3, click on an object and go to its settings, there is a Metadata section where you can add your own headers. Just click "Add Metadata."

This can also be done programmatically when loading data. All api supports additional metadata.

0
source

Source: https://habr.com/ru/post/1651249/


All Articles