Skip to content

Commit

Permalink
feat: add staging support for API url in apolloClient
Browse files Browse the repository at this point in the history
  • Loading branch information
amalv committed Jan 9, 2024
1 parent 61d4f58 commit 88099fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
VITE_API_URL_PRODUCTION: ${{ secrets.VITE_API_URL_PRODUCTION }}
VITE_AUTH0_DOMAIN: ${{ secrets.VITE_AUTH0_DOMAIN }}
VITE_AUTH0_CLIENT_ID: ${{ secrets.VITE_AUTH0_CLIENT_ID }}
VITE_ENV: production
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
Expand Down
10 changes: 7 additions & 3 deletions src/apolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ export const darkModeVar = makeVar(
window?.matchMedia("(prefers-color-scheme: dark)")?.matches
);

const API_URL =
import.meta.env.VITE_API_URL_PRODUCTION ||
import.meta.env.VITE_API_URL_DEVELOPMENT;
const apiUrlMap = {
production: import.meta.env.VITE_API_URL_PRODUCTION,
staging: import.meta.env.VITE_API_URL_STAGING,
development: import.meta.env.VITE_API_URL_DEVELOPMENT,
};

const API_URL = apiUrlMap[import.meta.env.VITE_ENV] || apiUrlMap.development;

Check failure on line 19 in src/apolloClient.ts

View workflow job for this annotation

GitHub Actions / build

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ production: any; staging: any; development: any; }'.

const httpLink = createHttpLink({
uri: API_URL,
Expand Down

0 comments on commit 88099fc

Please sign in to comment.