Skip to content

Commit

Permalink
Set react httpLink through env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
alepbloyd committed Aug 22, 2024
1 parent 6224b6a commit f81d783
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Generate rails credentials
# Run `rails credentials:help` for instructions

RAILS_MASTER_KEY=
POSTGRES_PASSWORD=

# Will be used as the database password
POSTGRES_PASSWORD=

# Set to the URL for the backend API. i.e.
# "ec2-instance-url.us-west-2.compute.amazon.com/graphql"
RAILS_API_URL="http://localhost:3001/graphql"
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ services:
env_file: .env
environment:
NODE_ENV: production
RAILS_API_URL: $RAILS_API_URL
ports:
- 3000:3000
- 3000:80
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --spider --tries=1 localhost:3000 || exit 1" ]
interval: 10s
Expand Down
2 changes: 1 addition & 1 deletion react/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SignInPage from "./components/pages/SignInPage.tsx";
import { setContext } from "@apollo/client/link/context";

const httpLink = new HttpLink({
uri: "http://localhost:3001/graphql",
uri: import.meta.env.RAILS_API_URL, // This probably needs to be the nginx address
});

const authLink = setContext((_, { headers }) => {
Expand Down

0 comments on commit f81d783

Please sign in to comment.