Skip to content

Commit

Permalink
Move server URI to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed Apr 24, 2024
1 parent 88affc5 commit 059c519
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SERVER_URI = process.env.REACT_APP_SERVER_URI ?? "http://localhost:8080"
12 changes: 5 additions & 7 deletions app/src/features/toolbar/hooks/useGithubAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useLocalSession } from '../../../utils/localStorage';
import { SERVER_URI } from '../../../constants';

interface AuthenticatedUser {
fullName: string;
Expand Down Expand Up @@ -57,7 +58,7 @@ export function useGithubAuth(): [AuthenticatedUser | null, () => void] {
const params = {
code: githubCode,
};
const request = new Request('http://localhost:8080/login', {
const request = new Request(`${SERVER_URI}/login`, {
method: 'POST',
body: JSON.stringify(params),
});
Expand Down Expand Up @@ -96,12 +97,9 @@ export function useGithubAuth(): [AuthenticatedUser | null, () => void] {
return;
}

const request = new Request(
`http://localhost:8080/session?id=${sessionId}`,
{
method: 'GET',
}
);
const request = new Request(`${SERVER_URI}/session?id=${sessionId}`, {
method: 'GET',
});
fetch(request)
.then((response) => {
if (response.status < 400) {
Expand Down

0 comments on commit 059c519

Please sign in to comment.