Skip to content

TransformRequest function to allow Custom Auth for each request #325

@james-willis

Description

@james-willis

In the zarr-gl and zarr-layer projects, we want to allow users to request data that requires authentication, for example from s3 using presigned URLs. We accomplish this by letting them provide a transformRequest method like that of MapLibre: https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/RequestParameters/

We have a PR to do that in zarr-layer but we think having zarrita support some kind of fetchFn parameter might be a good idea for other zarrita users. It would also simplify the code in zarr-layer for this feature. PR for zarr-layer support: carbonplan/zarr-layer#6

zarr-js sovles this by allowing the passing of a custom fetch function when creating a store:

zarr(fetchFn, "v3").open(
  `${source}/${level}/${variable}`,
  (err: Error, get: Loader) => {
    if (err) {
      reject(err);
      return;
    }
    resolve([`${level}/${variable}`, get]);
  },
);

where fetchFn implements the interface of window.fetch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions