Skip to content

Commit

Permalink
hardcode ROOT_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
seplee committed Apr 14, 2024
1 parent 6483a90 commit aea9ab9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion web/src/.env.production

This file was deleted.

1 change: 0 additions & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <UnauthenticatedTemplate loginCallback={handleLogin} />;
Expand Down
16 changes: 9 additions & 7 deletions web/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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": "*",
Expand All @@ -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": "*",
Expand All @@ -56,7 +58,7 @@ export const getSplit = async (text: string): Promise<string[]> => {
text: text,
};

return fetch(`${process.env.REACT_APP_API_ROOT}/split`, {
return fetch(`${API_ROOT}/split`, {
method: "POST",
headers: {
"content-type": "application/json",
Expand All @@ -76,7 +78,7 @@ export const getSplit = async (text: string): Promise<string[]> => {
};

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",
Expand All @@ -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",
Expand Down Expand Up @@ -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": "*",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion web/src/component/OAuthLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit aea9ab9

Please sign in to comment.