diff --git a/frontend/frontend/src/api/user.js b/frontend/frontend/src/api/user.js index 578cb5ca..ca42b25e 100644 --- a/frontend/frontend/src/api/user.js +++ b/frontend/frontend/src/api/user.js @@ -1,7 +1,7 @@ import axios from 'axios'; import { v4 as uuidv4 } from 'uuid'; -import { BACKEND_URL } from '../constants'; +import { BACKEND_URL, HOST } from '../constants'; const URL_PREFIX = BACKEND_URL; @@ -19,7 +19,7 @@ const setUserKey = async (code) => { const authenticate = async (code, privateAccess, userKey) => { try { - const fullUrl = `https://github-readme-stats-phi-jet-58.vercel.app/api/authenticate?code=${code}&private_access=${privateAccess}&user_key=${userKey}`; + const fullUrl = `https://${HOST}/api/authenticate?code=${code}&private_access=${privateAccess}&user_key=${userKey}`; const result = await axios.post(fullUrl); return result.data; } catch (error) { @@ -30,7 +30,7 @@ const authenticate = async (code, privateAccess, userKey) => { const getUserMetadata = async (userKey) => { try { - const fullUrl = `https://github-readme-stats-phi-jet-58.vercel.app/api/private-access?user_key=${userKey}`; + const fullUrl = `https://${HOST}/api/private-access?user_key=${userKey}`; const result = await axios.get(fullUrl); return result.data; } catch (error) { @@ -41,7 +41,7 @@ const getUserMetadata = async (userKey) => { const deleteAccount = async (userId, userKey) => { try { - const fullUrl = `https://github-readme-stats-phi-jet-58.vercel.app/api/delete-user?user_key=${userKey}`; + const fullUrl = `https://${HOST}/api/delete-user?user_key=${userKey}`; const result = await axios.get(fullUrl); return result.data; // no decorator } catch (error) { diff --git a/frontend/frontend/src/components/Card/Card.js b/frontend/frontend/src/components/Card/Card.js index 8ecaae66..31838bcb 100644 --- a/frontend/frontend/src/components/Card/Card.js +++ b/frontend/frontend/src/components/Card/Card.js @@ -3,9 +3,10 @@ import PropTypes from 'prop-types'; import SVG from './SVG'; import { classnames } from '../../utils'; +import { HOST } from '../../constants'; export const Image = ({ imageSrc, compact, extraClasses = '' }) => { - const fullImageSrc = `https://github-readme-stats-phi-jet-58.vercel.app/api/${imageSrc}&client=wizard`; + const fullImageSrc = `https://${HOST}/api/${imageSrc}&client=wizard`; return (
diff --git a/frontend/frontend/src/pages/App/AppTrends.js b/frontend/frontend/src/pages/App/AppTrends.js index 5d9b45e5..b4e30c16 100644 --- a/frontend/frontend/src/pages/App/AppTrends.js +++ b/frontend/frontend/src/pages/App/AppTrends.js @@ -3,16 +3,8 @@ import React, { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { - BrowserRouter as Router, - Route, - Routes, - useParams, -} from 'react-router-dom'; -import { - logout as _logout, - setPrivateAccess as _setPrivateAccess, -} from '../../redux/actions/userActions'; +import { BrowserRouter as Router, Route, Routes, useParams, } from 'react-router-dom'; +import { logout as _logout, setPrivateAccess as _setPrivateAccess, } from '../../redux/actions/userActions'; import Header from './Header'; import LandingScreen from '../Landing'; @@ -20,7 +12,7 @@ import DemoScreen from '../Demo'; import { SignUpScreen } from '../Auth'; import HomeScreen from '../Home'; import SettingsScreen from '../Settings'; -import { NoMatchScreen, RedirectScreen } from '../Misc'; +import { NoMatchScreen } from '../Misc'; import { getUserMetadata } from '../../api'; import { WRAPPED_URL } from '../../constants'; import Footer from './Footer'; @@ -84,7 +76,6 @@ function App() { } /> )} } /> - } /> } diff --git a/frontend/frontend/src/pages/Demo/Demo.js b/frontend/frontend/src/pages/Demo/Demo.js index 4ebba8b4..47bda64e 100644 --- a/frontend/frontend/src/pages/Demo/Demo.js +++ b/frontend/frontend/src/pages/Demo/Demo.js @@ -4,7 +4,7 @@ import { Link } from 'react-router-dom'; import { Button, SvgInline } from '../../components'; import { getValidUser } from '../../api/wrapped'; -import { BACKEND_URL } from '../../constants'; +import { HOST } from '../../constants'; import { classnames } from '../../utils'; const DemoScreen = () => { @@ -33,13 +33,13 @@ const DemoScreen = () => { const firstCardUrl = selectedUserName.length > 0 - ? `https://github-readme-stats-phi-jet-58.vercel.app/api/?username=${selectedUserName}&client=demo` - : `${BACKEND_URL}/user/svg/demo?card=langs`; // TODO: placeholder image + ? `https://${HOST}/api/?username=${selectedUserName}&client=demo` + : `https://${HOST}/api/?username=anuraghazra&client=demo`; const secondCardUrl = selectedUserName.length > 0 - ? `https://github-readme-stats-phi-jet-58.vercel.app/api/top-langs/?username=${selectedUserName}&client=demo` - : `${BACKEND_URL}/user/svg/demo?card=repos`; // TODO: placeholder image + ? `https://${HOST}/api/top-langs/?username=${selectedUserName}&client=demo` + : `https://${HOST}/api/top-langs/?username=anuraghazra&client=demo`; return (
diff --git a/frontend/frontend/src/pages/Home/stages/Display.js b/frontend/frontend/src/pages/Home/stages/Display.js index 1521f714..ad235665 100644 --- a/frontend/frontend/src/pages/Home/stages/Display.js +++ b/frontend/frontend/src/pages/Home/stages/Display.js @@ -3,13 +3,14 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { ToastContainer, toast } from 'react-toastify'; +import { toast, ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { saveSvgAsPng } from 'save-svg-as-png'; -import { Card, Button } from '../../../components'; +import { Button, Card } from '../../../components'; import { classnames } from '../../../utils'; +import { HOST } from '../../../constants'; const DisplayStage = ({ userId, themeSuffix }) => { const card = themeSuffix.split('?')[0]; @@ -27,7 +28,7 @@ const DisplayStage = ({ userId, themeSuffix }) => { const copyUrl = () => { navigator.clipboard.writeText( - `https://github-readme-stats-phi-jet-58.vercel.app/api/${themeSuffix}&username=${userId}`, + `https://${HOST}/api/${themeSuffix}&username=${userId}`, ); toast.info('Copied to Clipboard!', { position: 'bottom-right', diff --git a/frontend/frontend/src/pages/Misc/Redirect.js b/frontend/frontend/src/pages/Misc/Redirect.js deleted file mode 100644 index bde9e449..00000000 --- a/frontend/frontend/src/pages/Misc/Redirect.js +++ /dev/null @@ -1,25 +0,0 @@ -// eslint-disable-next-line no-unused-vars -import React, { useEffect } from 'react'; -import { BACKEND_URL } from '../../constants'; - -const RedirectScreen = () => { - useEffect(() => { - async function redirectCode() { - // Take any query parameters and pass to redirect - const url = window.location.href; - const hasCode = url.includes('user/redirect'); - - // If Github API returns the code parameter - if (hasCode) { - const newUrl = url.split('user/redirect'); - window.location.replace(`${BACKEND_URL}/auth/redirect${newUrl[1]}`); - } - } - - redirectCode(); - }, []); - - return null; -}; - -export default RedirectScreen; diff --git a/frontend/frontend/src/pages/Misc/index.js b/frontend/frontend/src/pages/Misc/index.js index afde4714..9106ac70 100644 --- a/frontend/frontend/src/pages/Misc/index.js +++ b/frontend/frontend/src/pages/Misc/index.js @@ -1,4 +1,3 @@ import NoMatchScreen from './NoMatch'; -import RedirectScreen from './Redirect'; -export { NoMatchScreen, RedirectScreen }; +export { NoMatchScreen }; diff --git a/frontend/frontend/src/pages/Settings/Settings.js b/frontend/frontend/src/pages/Settings/Settings.js index a9f6c68c..13961835 100644 --- a/frontend/frontend/src/pages/Settings/Settings.js +++ b/frontend/frontend/src/pages/Settings/Settings.js @@ -9,7 +9,7 @@ import { Button } from '../../components'; import { logout as _logout } from '../../redux/actions/userActions'; import { deleteAccount } from '../../api'; import { classnames } from '../../utils'; -import { CLIENT_ID, GITHUB_PRIVATE_AUTH_URL } from '../../constants'; +import { CLIENT_ID, GITHUB_PRIVATE_AUTH_URL, HOST } from '../../constants'; const SectionButton = ({ name, implemented, isSelected, setSelected }) => { return ( @@ -168,7 +168,7 @@ const SettingsScreen = () => {
{privateAccess ? (