Skip to content

Commit

Permalink
Merge pull request #59 from NASA-IMPACT/add-gis-token
Browse files Browse the repository at this point in the history
Add VITE_GIS_TOKEN to the image service request
  • Loading branch information
amarouane-ABDELHAK authored Oct 7, 2024
2 parents 6188ce7 + 107ad20 commit 977667f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 977667f

Please sign in to comment.