Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 15 add local login page url #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_API_URL='http://localhost:3000/api/v1/'
REACT_APP_API_PATH=
REACT_APP_BACK_BASE_URL=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je dirais qu'on peut remplacer BACK par API, pour indiquer que c'est la même application. Ça permet de moins se poser de questions.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"test:serve": "REACT_APP_API_URL=/api/v1 BROWSER=none yarn start",
"test:serve": "REACT_APP_API_PATH=/api/v1 BROWSER=none yarn start",
"cypress:open": "cypress open",
"cypress:run": "cypress run --record",
"test:ui": " start-server-and-test test:serve 3000 cypress:run"
Expand Down
5 changes: 4 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import * as serviceWorker from "./serviceWorker";
import { Theme } from "./ui/Theme/Theme";

const authToken = getOauthTokenOrRedirect();
const apiUrl = process.env.REACT_APP_API_URL!;

const apiPath = process.env.REACT_APP_API_PATH!;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas sûr que ce soit nécessaire de variabiliser le path de l'API. Ce n'est pas comme si on avait plusieurs versions de l'API pour l'instant.

Suggested change
const apiPath = process.env.REACT_APP_API_PATH!;
const apiPath = "/api/v1";


const apiUrl = `${process.env.REACT_APP_BACK_BASE_URL}${apiPath}`;

const httpClient = createHttpClient(apiUrl, authToken);

Expand Down
3 changes: 1 addition & 2 deletions src/utils/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export function getOauthTokenOrRedirect(): string {
return "";
}

export const LOGIN_PAGE_URL =
"https://octo-moss-back.herokuapp.com/auth/google_oauth2";
const LOGIN_PAGE_URL = `${process.env.REACT_APP_BACK_BASE_URL}/auth/google_oauth2`;

export function redirectToLoginPage() {
window.location.href = `${LOGIN_PAGE_URL}?redirect_to=${window.location.href}`;
Expand Down