Skip to content

Commit

Permalink
Merge pull request #64 from NASA-IMPACT/develop
Browse files Browse the repository at this point in the history
Add Token auth for gis servers
  • Loading branch information
amarouane-ABDELHAK authored Oct 7, 2024
2 parents 7b84d6b + 3b1b1f0 commit 944b8f0
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 944b8f0

Please sign in to comment.