From aea9ab9c50808c9c9d60ef6e478548ddf399ea1f Mon Sep 17 00:00:00 2001 From: Lee Harrold Date: Sun, 14 Apr 2024 08:07:37 -0400 Subject: [PATCH] hardcode ROOT_URL --- .github/workflows/build-deploy.yml | 4 +--- web/src/.env.production | 1 - web/src/App.tsx | 1 - web/src/api.ts | 16 +++++++++------- web/src/component/OAuthLogin.tsx | 3 ++- 5 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 web/src/.env.production diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index eb1e122..ce5d8a7 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -21,15 +21,13 @@ jobs: - name: Build FE run: | - echo ${{ vars.REACT_APP_API_ROOT }} cd web npm install - name: Build FE run: | cd web - npm run build-production - # FE build will be in build + npm run build - uses: actions/upload-artifact@v4 with: diff --git a/web/src/.env.production b/web/src/.env.production deleted file mode 100644 index 7d176bf..0000000 --- a/web/src/.env.production +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_API_ROOT=https://drive-gooder.com/api \ No newline at end of file diff --git a/web/src/App.tsx b/web/src/App.tsx index 3b99424..479c5e7 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -14,7 +14,6 @@ function App() { // send a request to a protected endpoint on the server for the user's info // if the response is successful, set loggedIn to true and redirect to protected route console.log(`logged in? ${loggedIn}`); - console.log(`root domain is: ${process.env.REACT_APP_API_ROOT}`); if (!loggedIn) { return ; diff --git a/web/src/api.ts b/web/src/api.ts index 831a674..8f07531 100644 --- a/web/src/api.ts +++ b/web/src/api.ts @@ -5,6 +5,8 @@ const credentials = { password: "", }; +const API_ROOT = "https://drive-gooder.com/api"; + export const storeLoginCredentials = (username: string, password: string) => { credentials.username = username; credentials.password = password; @@ -21,7 +23,7 @@ const buildAuthorizationHeader = (username: string, password: string) => { export const authenticate = async (username: string, password: string) => { return axios - .post(`${process.env.REACT_APP_API_ROOT}/authenticate`, null, { + .post(`${API_ROOT}/authenticate`, null, { headers: { "content-type": "application/json", "Access-Control-Allow-Origin": "*", @@ -39,7 +41,7 @@ export const authenticate = async (username: string, password: string) => { export const oauth = async () => { return axios - .get(`${process.env.REACT_APP_API_ROOT}/login`, { + .get(`${API_ROOT}/login`, { headers: { "content-type": "application/json", "Access-Control-Allow-Origin": "*", @@ -56,7 +58,7 @@ export const getSplit = async (text: string): Promise => { text: text, }; - return fetch(`${process.env.REACT_APP_API_ROOT}/split`, { + return fetch(`${API_ROOT}/split`, { method: "POST", headers: { "content-type": "application/json", @@ -76,7 +78,7 @@ export const getSplit = async (text: string): Promise => { }; export const getUserInfo = async () => { - return await fetch(`${process.env.REACT_APP_API_ROOT}/me`, { + return await fetch(`${API_ROOT}/me`, { method: "GET", headers: { "content-type": "application/json", @@ -102,7 +104,7 @@ export const readText = (text: string, emotion: string, speed: number) => { speed, }; - return fetch(`${process.env.REACT_APP_API_ROOT}/read`, { + return fetch(`${API_ROOT}/read`, { method: "POST", headers: { "content-type": "application/json", @@ -133,7 +135,7 @@ export const ask = ( formData.set("speed", speed.toString()); formData.set("question.wav", audio); - return fetch(`${process.env.REACT_APP_API_ROOT}/ask`, { + return fetch(`${API_ROOT}/ask`, { method: "POST", headers: { "Access-Control-Allow-Origin": "*", @@ -162,7 +164,7 @@ export const summarize = ( speed, }; - return fetch(`${process.env.REACT_APP_API_ROOT}/summarize`, { + return fetch(`${API_ROOT}/summarize`, { method: "POST", headers: { "content-type": "application/json", diff --git a/web/src/component/OAuthLogin.tsx b/web/src/component/OAuthLogin.tsx index 6181e7d..5e3411c 100644 --- a/web/src/component/OAuthLogin.tsx +++ b/web/src/component/OAuthLogin.tsx @@ -3,9 +3,10 @@ import { FormControl, Button, Box } from "@mui/material"; export interface OAuthLoginProps { loginCallback: VoidFunction; } +const API_ROOT = "https://drive-gooder.com/api"; export default function OAuthLogin(props: OAuthLoginProps) { const handleOauth = () => { - window.open(`${process.env.REACT_APP_API_ROOT}/login`, "_self"); + window.open(`${API_ROOT}/login`, "_self"); }; return (