set up staging frontend to use staging backend

This commit is contained in:
Tao Bror Bojlén 2019-07-17 23:51:49 +03:00
parent f1241bb486
commit 6cd1260d5f
No known key found for this signature in database
GPG Key ID: C6EC7AAB905F9E6F
3 changed files with 23 additions and 2 deletions

View File

@ -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>

View File

@ -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 Normal file
View File

@ -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"