Simplifying CORS Configurations for IPFS Pinning

Simplifying CORS Configurations for IPFS Pinning

At Filebase, we're always striving to make decentralized storage more accessible and user-friendly. Our platform provides a powerful S3-compatible API to interact with the InterPlanetary File System (IPFS), simplifying the process of pinning and managing your content. Now, we’re excited to announce a new feature designed to enhance flexibility for developers working with IPFS: CORS Configurations.

What is CORS?

Cross-Origin Resource Sharing (CORS) is a security feature that controls how resources hosted on a web server can be requested from different domains. By configuring CORS, you can decide who can interact with your stored data and how they can access it.

With the new CORS Configurations feature on Filebase, managing CORS policies is now easier than ever. While we’ve always supported the GetBucketCors and PutBucketCors methods through our S3 API, we’re thrilled to offer a simplified, intuitive interface for creating, updating, and deleting CORS policies directly from your Filebase dashboard. When set, these policies are applied to all S3 API requests made against your bucket.

CORS Configuration Options

In the Filebase dashboard, you now have four distinct CORS policy options to choose from:

1. No CORS

This option effectively disables CORS for your bucket, meaning no cross-origin requests will be allowed. This is a secure choice if you don't want to allow any external access to your data.

2. Public Read-Only

The Public Read-Only policy allows only GET and HEAD requests. This means that external applications or websites can retrieve data from your bucket without modifying or adding to it. If you’re looking to publicly share content (like images, videos, or other static assets), this policy is ideal.

3. Public Read-Write

The Public Read-Write policy grants broader access to your bucket, allowing GET, HEAD, PUT, POST, and DELETE requests. This is useful for use cases where both reading and writing to your bucket are required by external applications. For example, this can be helpful in collaborative environments where multiple users or applications need to upload and manage content.

4. Custom

For those who require full control, the Custom policy option allows you to define a custom CORS configuration using JSON. This option is perfect if you have specific needs for how different HTTP methods, origins, or headers should be handled.

Here’s a quick example of a custom CORS policy:

[
  {
    "AllowedOrigins": [
      "*"
    ],
    "AllowedMethods": [
      "GET",
      "PUT",
      "DELETE"
    ],
    "AllowedHeaders": [
      "Authorization",
      "Content-Type"
    ],
    "ExposeHeaders": [
      "x-amz-meta-cid"
    ],
    "MaxAgeSeconds": 3000
  }
]

With this policy, all origins are allowed, and the methods GET, PUT, and DELETE can be used. The policy also sets a maximum cache age for preflight responses of 3000 seconds.

How to Manage CORS Policies on Filebase

Managing your CORS policies is as simple as heading to your Filebase dashboard. From there, you’ll find a new Configure CORS tab under each of your buckets, where you can easily select or create the policy that best suits your needs.

  1. Navigate to your bucket settings.
  2. Select the Configure CORS menu option.
  3. Choose one of the pre-configured policies or define your own policy.
  4. Save your settings and your policy will be applied instantly.

Why Use CORS with Filebase?

CORS is essential for web applications that interact with IPFS data stored on Filebase, especially when accessed from different domains or through various front-end applications. With the ability to set and manage CORS policies from our dashboard, we’re making it simpler for developers to build secure, decentralized applications with seamless cross-origin resource sharing.

Get Started with CORS Configurations

If you’re ready to get started, log in to your Filebase account and navigate to your bucket settings. Whether you need to quickly set up public access to your data or define a custom policy for advanced use cases, Filebase’s new CORS Configurations feature has you covered.

We’re committed to enhancing your experience with IPFS and decentralized storage, and we can’t wait to see how you’ll leverage these new capabilities!