I'm building an aplication using leaflet JS for a company and i want to use the esri basemaps URL to get the tiles for the map. By following the tutorials I got a solution where I created an API key that I use to get this information, but it exposes the API Key in the js. I did not like this approach so I built an API endpoint that act as a middleware and joins the esri basemaps URL with the API key token. However this approach proves enificient since some HTTP get request take several seconds to return.
I am using plain HTML and js with the library Leaflet, I may use the Esri-leaflet integration library but the problem persist.
Am I missing something, or is there another approach to solve this problem?