Skip to content

Commit

Permalink
Merge pull request #8 from gempesaw/dg/frontend-env-vars-for-finding-…
Browse files Browse the repository at this point in the history
…backend

Let the frontend specify where the backend is via env vars
  • Loading branch information
mortenmj authored Oct 3, 2024
2 parents 94fad13 + 76c2c68 commit 207c496
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ From `./frontend`, run:
npm run dev
```

### Change where the backend listens

You can run the backend on different bind addresses, but you'll need to update
the frontend too:

```
go run ../cmd/bb_portal/main.go --bind-http=:9091 --bind-grpc=:9092 &
NEXT_PUBLIC_BES_BACKEND_URL=http://localhost:9091 NEXT_PUBLIC_BES_GRPC_BACKEND_URL=grpc://localhost:9092 npm run dev
```

## Using the Application

Go to http://localhost:8081.
Expand Down
2 changes: 2 additions & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_BES_BACKEND_URL=http://localhost:8081
NEXT_PUBLIC_BES_GRPC_BACKEND_URL=grpc://localhost:8082
2 changes: 1 addition & 1 deletion frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './page.module.css';
import Content from '@/components/Content';
import Uploader from '@/components/Uploader';

const bazelrcLines = 'build --bes_backend=grpc://localhost:8082\nbuild --bes_results_url=http://localhost:8081/bazel-invocations/';
const bazelrcLines = `build --bes_backend=${process.env.NEXT_PUBLIC_BES_GRPC_BACKEND_URL}\nbuild --bes_results_url=${process.env.NEXT_PUBLIC_BES_BACKEND_URL}/bazel-invocations/`;

export default function Home() {
return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ApolloWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import possibleTypes from './possibleTypes.json';

export const makeClient = () => {
const httpLink = new HttpLink({
uri: "http://localhost:8081/graphql",
uri: `${process.env.NEXT_PUBLIC_BES_BACKEND_URL}/graphql`,
fetchOptions: { cache: "no-store" },
});

Expand Down

0 comments on commit 207c496

Please # to comment.