Skip to content

Commit

Permalink
Setup ENV Variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Akash Singh committed Mar 15, 2024
1 parent d93d0b5 commit c3bff84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions documentation/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
15 changes: 8 additions & 7 deletions documentation/src/context/CommunityStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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();
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down

0 comments on commit c3bff84

Please sign in to comment.