Skip to content

Commit

Permalink
feat: add environment variable for production API URL
Browse files Browse the repository at this point in the history
  • Loading branch information
amalv committed Dec 18, 2023
1 parent d7ca3da commit f1029ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
run: npm install
- name: Build
run: npm run build
env:
VITE_API_URL_PRODUCTION: ${{ secrets.VITE_API_URL_PRODUCTION }}
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
7 changes: 3 additions & 4 deletions src/apolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ApolloClient, InMemoryCache } from "@apollo/client";

const isProduction = process.env.NODE_ENV === "production";
const API_URL = isProduction
? import.meta.env.VITE_API_URL_PRODUCTION
: import.meta.env.VITE_API_URL_DEVELOPMENT;
const API_URL =
import.meta.env.VITE_API_URL_PRODUCTION ||
import.meta.env.VITE_API_URL_DEVELOPMENT;

export const client = new ApolloClient({
uri: API_URL,
Expand Down

0 comments on commit f1029ed

Please sign in to comment.