Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REACT_APP_API=DEV
REACT_APP_DEV_API_URL=http://localhost:4000/graphql
REACT_APP_PROD_API_URL=https://geornal-backend.herokuapp.com/graphql
DANGEROUSLY_DISABLE_HOST_CHECK=true
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ This will run the application in development mode, which will ensure the updates

### Running the API

In many cases you will need to also run the Travel Map API alongside this project.
When running the application locally you must connect to a valid API for handling requests. You can either utilize a local backend server or the production website. To toggle between these configurations, update the the following line in your `.env` file:

**To Use Locally Hosted API**

```
REACT_APP_API=DEV
```

**To Use Production Website's API**

```
REACT_APP_API=PROD
```

Please see [travel-map-api](https://github.com/projectunic0rn/travel-map-api) for more information on how to setup and install the API.

Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ if (localStorage.getItem("token")) {
}

let clientUrl = "";
if (process.env.NODE_ENV === "production") {
if (process.env.NODE_ENV === "production" || process.env.REACT_APP_API === "PROD") {
clientUrl = process.env.REACT_APP_PROD_API_URL;
} else if (process.env.REACT_APP_TEST_API_URL != null) {
clientUrl = process.env.REACT_APP_TEST_API_URL;
} else {
} else if (process.env.REACT_APP_API === "DEV") {
clientUrl = process.env.REACT_APP_DEV_API_URL;
}

const client = new ApolloClient({
uri: clientUrl,
request: async (operation) => {
Expand Down