Skip to content

Commit

Permalink
Merge pull request #4750 from wri/develop
Browse files Browse the repository at this point in the history
PROD Deploy 2024-02-19 10:32am EST
  • Loading branch information
wri7tno authored Feb 19, 2024
2 parents fb53481 + df4b7d1 commit c174df2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 21 deletions.
6 changes: 1 addition & 5 deletions components/header/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
isVisibleOnMobile: false,
submenu: [
{
label: 'Tutorials',
label: 'Help Center',
href: '/help/',
},
/* // TODO: enable these 2 links when we have the real urls
Expand All @@ -25,10 +25,6 @@ export default {
href: '/faq/',
},
*/
{
label: 'Community Forum',
extLink: 'https://groups.google.com/forum/#!forum/globalforestwatch/',
},
{
label: 'Grants & Opportunities',
href: '/grants-and-fellowships/projects/',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
"@next/bundle-analyzer": "^10.0.1",
"@reduxjs/toolkit": "^1.4.0",
"@wordpress/api-fetch": "^3.19.1",
"@worldresources/gfw-components": "^3.5.0",
"@worldresources/gfw-components": "^3.5.4",
"aws-sdk": "^2.291.0",
"axios": "^0.21.1",
"axios": "1.6.7",
"chroma-js": "^2.1.0",
"classnames": "^2.2.6",
"cookie": "^0.4.1",
Expand Down
30 changes: 21 additions & 9 deletions utils/request.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CancelToken, create } from 'axios';
import axios, { CancelToken } from 'axios';
import wriAPISerializer from 'wri-json-api-serializer';

import {
Expand Down Expand Up @@ -27,25 +27,30 @@ const RESOURCE_WATCH_API_URL = RESOURCE_WATCH_API;

// At the moment, the API key is the same
const GFW_API_KEY = process.env.NEXT_PUBLIC_GFW_API_KEY;
const GFW_METADATA_API_KEY = GFW_API_KEY;
const DATA_API_KEY = GFW_API_KEY;
const RESOURCE_WATCH_API_KEY = GFW_API_KEY;

const isServer = typeof window === 'undefined';

const defaultRequestConfig = {
timeout: 30 * 1000,
};

export const apiRequest = create({
export const apiRequest = axios.create({
...defaultRequestConfig,
...(isServer && {
baseURL: GFW_API_URL,
headers: {
'x-api-key': GFW_API_KEY,
},
}),
...(!isServer && {
baseURL: PROXIES.GFW_API,
}),
});

export const dataRequest = create({
export const dataRequest = axios.create({
...defaultRequestConfig,
...(isServer && {
baseURL: DATA_API_URL,
Expand All @@ -59,33 +64,40 @@ export const dataRequest = create({
transformResponse: [(data) => JSON.parse(data)?.data],
});

export const metadataRequest = create({
export const metadataRequest = axios.create({
...defaultRequestConfig,
...(isServer && {
baseURL: GFW_METADATA_API_URL,
headers: {
'x-api-key': GFW_METADATA_API_KEY,
},
}),
...(!isServer && {
baseURL: PROXIES.METADATA_API,
}),
});

export const rwRequest = create({
export const rwRequest = axios.create({
...defaultRequestConfig,
...(isServer && {
baseURL: RESOURCE_WATCH_API_URL,
headers: {
'x-api-key': RESOURCE_WATCH_API_KEY,
},
}),
...(!isServer && {
baseURL: PROXIES.RESOURCE_WATCH_API,
}),
transformResponse: [(data) => wriAPISerializer(JSON.parse(data))],
});

export const apiAuthRequest = create({
export const apiAuthRequest = axios.create({
...defaultRequestConfig,
...(isServer && {
baseURL: GFW_API,
headers: {
'content-type': 'application/json',
'x-api-key': GFW_API_KEY,
},
}),
...(!isServer && {
Expand All @@ -97,18 +109,18 @@ export const apiAuthRequest = create({
}),
});

export const cartoRequest = create({
export const cartoRequest = axios.create({
...defaultRequestConfig,
baseURL: CARTO_API,
});

export const mapboxRequest = create({
export const mapboxRequest = axios.create({
...defaultRequestConfig,
baseURL: MAPBOX_API,
});

export const cancelToken = () => CancelToken.source();

export default create({
export default axios.create({
...defaultRequestConfig,
});
29 changes: 24 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3945,10 +3945,10 @@
lodash "^4.17.19"
react-native-url-polyfill "^1.1.2"

"@worldresources/gfw-components@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@worldresources/gfw-components/-/gfw-components-3.5.0.tgz#e2069f334fbbfd67aa8d881f8ea3407a06ff7fc8"
integrity sha512-/Hx1Zg17PTi4yZSxxIB4oDyHaxQ5YxEopn5WoTHZdDBytCmeJGaaTRbypA7wHZMEkgxN2ywSCTVyeX68p80N3g==
"@worldresources/gfw-components@^3.5.4":
version "3.5.4"
resolved "https://registry.yarnpkg.com/@worldresources/gfw-components/-/gfw-components-3.5.4.tgz#1d1d74073c0bf70a34e94294bf8b7e2e8d9ed5ec"
integrity sha512-//OAjp3RmHw0yO/V4FTgEkJvuzj2olnQou3ygdWjWy0wnPgoBUV2aTwfUGcnBX7kQt8WBz2kFtp8ZxC8mRtNJQ==
dependencies:
"@artsy/fresnel" "^1.1.0"
"@tippyjs/react" "^4.0.2"
Expand Down Expand Up @@ -4573,13 +4573,22 @@ axe-core@^4.6.2:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.7.2.tgz#040a7342b20765cb18bb50b628394c21bccc17a0"
integrity sha512-zIURGIS1E1Q4pcrMjp+nnEh+16G56eG/MUllJH8yEvw7asDo7Ac9uhC9KIH5jzpITueEZolfYglnCGIuSBz39g==

[email protected], axios@^0.21.1:
[email protected]:
version "0.21.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
dependencies:
follow-redirects "^1.14.0"

[email protected]:
version "1.6.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
dependencies:
follow-redirects "^1.15.4"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^0.19.0, axios@^0.19.2:
version "0.19.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
Expand Down Expand Up @@ -8398,6 +8407,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.0, follow-redirects@^1.14.9:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==

follow-redirects@^1.15.4:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==

for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
Expand Down Expand Up @@ -13844,6 +13858,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee"
integrity sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A==

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.2.0.tgz#5e7425b89508736cdd4f2224d028f7bb3f722ebd"
Expand Down

0 comments on commit c174df2

Please sign in to comment.