1

I am trying to hide the APIKEY in the network requests that the map is using. I am using "@deck.gl/carto": "version": "8.6.5"

The api is set with

setDefaultCredentials({
  username: environment.carto_account,
  apiKey: environment.carto_api_key
});

The layer is being created this way:

new CartoLayer({
    type: MAP_TYPES.QUERY,
    pickable: true,
    id: 'countyborders',
    data: `SELECT * FROM ${CARTO.COUNTY_TABLE}`,
    getFillColor: [180,180,180,0],
    stroked: true,
    lineWidthMinPixels: 1,
    getLineColor: [ 98, 110, 120, 50 ],
  })

and added to the map this way:

<DeckGL layers={layers}> 

then in the network to get the data we see something like:

https://maps-api-v2.us.carto.com/user/{profile-name}/carto/sql?source={QUERY}&format=tilejson&api_key={API_KEY}&client=deck-gl-carto

but we dont want to display the API_KEY to the public.

How can we keep using deckgl and carto this way and hiding this API_KEY?

I wanted to make a proxy pass through the backend, but can't seem to figure out how to use the deckgl and cartolayer pointing to a custom api not the default maps-api-v2...

Jorge Monroy
  • 408
  • 1
  • 5
  • 16

0 Answers0