Search code examples
deck.gl

Is there a way to pass basic auth header options when retrieving a deck.gl layer?


I am looking to create an MVTLayer from a private repository that is wrapped with a basic authorization header. I was looking through the source code and don't see a way to pass additional header options to the POST. Is there a way to pass a header when retrieving a deck.gl layer?


Solution

  • Take a look at the loadOptions property of MVTLayer. Anything you pass in there will get passed through to the native fetch.

    For example,

    const myLayer = new MVTLayer({
      // ...
      loadOptions:
        fetch: {
          headers: {
            Authorization: 'Basic ' + btoa('login:password'))
          }
        }
      }
    });
    

    see example here: https://deck.gl/docs/developer-guide/loading-data