Skip to content

Commit

Permalink
Use environment variable to point to local server
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed Mar 18, 2024
1 parent 67014fa commit 58dcde3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ npm start

This will open http://localhost:3000 in your browser. By default, it will use the production backend endpoint.

To test against the backend running locally, make this change in `app/src/constants.ts`:
To test against the backend running locally, you can use the environment variable `REACT_APP_LOCAL_SERVER` when you start the app, like this:

```diff
- export const SERVER_URI = 'https://api.sway-playground.org';
- // export const SERVER_URI = 'http://0.0.0.0:8080';
+ // export const SERVER_URI = 'https://api.sway-playground.org';
+ export const SERVER_URI = 'http://0.0.0.0:8080';
```sh
REACT_APP_LOCAL_SERVER=true npm start
```

## Contributing to Sway
Expand Down
6 changes: 3 additions & 3 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const FUEL_GREEN = '#00f58c';

// TODO: Determine the URL based on the NODE_ENV.
export const SERVER_URI = 'https://api.sway-playground.org';
// export const SERVER_URI = 'http://0.0.0.0:8080';
export const SERVER_URI = process.env.REACT_APP_LOCAL_SERVER
? 'http://0.0.0.0:8080'
: 'https://api.sway-playground.org';

export const DEFAULT_SWAY_CONTRACT = `contract;
Expand Down

0 comments on commit 58dcde3

Please sign in to comment.