diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b654dc6..957da6e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -72,6 +72,8 @@ jobs: GOOGLE_TAG_MANAGER_ID: ${{secrets.GOOGLE_TAG_MANAGER_ID}} GOOGLE_TAG_AUTH: ${{secrets.GOOGLE_TAG_AUTH}} GOOGLE_TAG_PREVIEW: ${{secrets.GOOGLE_TAG_PREVIEW}} + VITE_GIS_TOKEN: ${{secrets.GIS_TOKEN}} + VITE_REFERER: ${{vars.GIS_REFERER}} run: | npm install npm run build diff --git a/src/utils/utils.js b/src/utils/utils.js index c89d5dc..1480dba 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -33,7 +33,15 @@ export const handleImageServiceRequest = async (event, variable, setChartData, s }; try { - const response = await fetch(url.toString(), { method: 'GET' }); + const token = import.meta.env.VITE_GIS_TOKEN ?? ''; + const referer = import.meta.env.VITE_REFERER ?? 'https://earth.gov'; + const response = await fetch(url.toString(), { + method: 'GET', + headers: { + 'X-Esri-Authorization': `Bearer ${token}`, + 'Referer': `${referer}`, + } + }); const results = await response.json(); // const results = mockData; // Uncomment this line to use mockData during testing