Learn how to configure a basic CORS rule for use with a Filebase bucket.
Cross-origin resource sharing (CORS) creates a way for client web applications located on one domain to have the ability to interact with resources located on a different domain. With CORS, websites and applications can access files and resources stored on Filebase buckets.
Creating a CORS Rule for a Filebase Bucket
The Filebase S3-compatible API supports CORS configurations for buckets.
The following API methods are supported:
To configure a Filebase bucket to allow cross-origin requests, you will need to create a CORS rule. This rule identifies the origins that you will allow to access your bucket, the HTTP methods that will be supported for each origin, and other operation specific information.
This rule can be a JSON or XML file, though if using AWS CLI to apply this rule, a .json file is required.
Example #1 JSON:
This example is a wildcard rule that allows cross-origin GET requests from all origins.
Example #1 XML:
Example #2 JSON:
CORS also allows optional configuration parameters, as shown in the following CORS rule.
MaxAgeSeconds: Specifies the amount of time in seconds that the browser caches a response to a preflight OPTIONS request for the specified resource.
ExposeHeader: Identifies the response headers that customers are able to access from their applications. In this example, x-amz-server-side-encryption, x-amz-request-id, and x-amz-id-2.
In this second example, the CORS rule allows cross-origin PUT, POST, and DELETE requests from the http://www.example.com origin, with a MaxAgeSeconds of 3000 and ExposeHeaders of x-amz-server-side-encryption, x-amz-request-id, and x-amz-id-2.