diff --git a/frontend/README.md b/frontend/README.md index d5b4fc9..0652bb2 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -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.
diff --git a/frontend/src/util.ts b/frontend/src/util.ts index 3ff0f3d..429ede0 100644 --- a/frontend/src/util.ts +++ b/frontend/src/util.ts @@ -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 => { const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/"; diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..4438afa --- /dev/null +++ b/netlify.toml @@ -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"