diff --git a/documentation/docusaurus.config.js b/documentation/docusaurus.config.js index 4a9b6e21..f29d0e6f 100644 --- a/documentation/docusaurus.config.js +++ b/documentation/docusaurus.config.js @@ -221,6 +221,14 @@ const siteConfig = { ] ), ], + webpack(config, { isServer, webpack }) { + config.plugins.push( + new webpack.DefinePlugin({ + 'process.env.REACT_APP_FOLLOWERS_ACCESS_KEY': JSON.stringify(process.env.REACT_APP_FOLLOWERS_ACCESS_KEY), + }) + ); + return config; + }, themeConfig: { prism: { theme: require("prism-react-renderer/themes/github"), diff --git a/documentation/src/context/CommunityStats/index.tsx b/documentation/src/context/CommunityStats/index.tsx index a5082fdb..f74e3063 100644 --- a/documentation/src/context/CommunityStats/index.tsx +++ b/documentation/src/context/CommunityStats/index.tsx @@ -33,6 +33,7 @@ interface ICommunityStatsContext { export const CommunityStatsContext = createContext< ICommunityStatsContext | undefined >(undefined); +const followersAccessKey = process.env.REACT_APP_FOLLOWERS_ACCESS_KEY || 'default_key'; export const CommunityStatsProvider: FC = ({ children }) => { const [loading, setLoading] = useState(true); @@ -62,7 +63,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, signal, }, @@ -74,7 +75,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, signal, }, @@ -90,7 +91,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, signal, }, @@ -112,7 +113,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, }); const FollowersFullDetails = await fetchFollowersFullDetails.json(); @@ -131,7 +132,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, signal, }, @@ -143,7 +144,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, signal, }, @@ -155,7 +156,7 @@ export const CommunityStatsProvider: FC = ({ children }) => { method: "GET", headers: { "Content-Type": "application/json", - "Authorization": `token ${process.env.REACT_APP_FOLLOWERS_ACCESS_KEY}`, + "Authorization": `token ${followersAccessKey}`, }, signal, },