set up staging frontend to use staging backend

pull/1/head
Tao Bror Bojlén 2019-07-17 23:51:49 +03:00
rodzic f1241bb486
commit 6cd1260d5f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: C6EC7AAB905F9E6F
3 zmienionych plików z 23 dodań i 2 usunięć

Wyświetl plik

@ -1,3 +1,11 @@
# fediverse.space frontend
The React frontend for [fediverse.space](https://fediverse.space). Written in Typescript.
- Set the environment variable `REACT_APP_STAGING=true` when building to use the staging backend.
# Default README
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
Below you will find some information on how to perform common tasks.<br>

Wyświetl plik

@ -1,7 +1,11 @@
import fetch from "cross-fetch";
const API_ROOT =
process.env.NODE_ENV === "development" ? "http://localhost:4000/api/" : "https://backend.fediverse.space/api/";
let API_ROOT = "http://localhost:4000/api/";
if (["true", true, 1, "1"].indexOf(process.env.REACT_APP_STAGING || "") > -1) {
API_ROOT = "https://phoenix.api-develop.fediverse.space/api/";
} else if (process.env.NODE_ENV === "production") {
API_ROOT = "https://phoenix.api.fediverse.space/api/";
}
export const getFromApi = (path: string): Promise<any> => {
const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/";

9
netlify.toml 100644
Wyświetl plik

@ -0,0 +1,9 @@
[build]
base = "frontend/"
publish = "frontend/build/"
[context.develop.environment]
REACT_APP_STAGING = "true"
[context.branch-deploy.environment]
REACT_APP_STAGING = "true"