set up staging frontend to use staging backend
This commit is contained in:
parent
f1241bb486
commit
6cd1260d5f
|
@ -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>
|
||||
|
|
|
@ -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
9
netlify.toml
Normal 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"
|
Loading…
Reference in a new issue