From 3ee263090e1a55413ac05fdec52050e9d3326d54 Mon Sep 17 00:00:00 2001 From: Pratik Borole Date: Sat, 4 May 2024 11:46:12 +0530 Subject: [PATCH] chore: add server url to .env --- .env.example | 4 +++- .github/workflows/lint.yml | 2 +- .gitignore | 1 + src/app/api/fetch.ts | 4 ++-- src/lib/constants.ts | 4 +++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 567c429..dd2d9b8 100644 --- a/.env.example +++ b/.env.example @@ -2,4 +2,6 @@ # Ideally, don't add them to production deployment envs # Change to true if we want to log data # NEXT_PUBLIC_SHOW_LOGGER="false" -NEXT_PUBLIC_BEARER_TOKEN="my-secret-token" \ No newline at end of file + +NEXT_PUBLIC_BEARER_TOKEN="my-secret-token" +NEXT_PUBLIC_SERVER_URL="http://127.0.0.1:8081" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0e28015..550e04a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d with: - version: 8 + version: 9 run_install: true - name: 🔬 Lint diff --git a/.gitignore b/.gitignore index c9fac46..f9a9b52 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ yarn-error.log* # local env files .env*.local +.env # vercel .vercel diff --git a/src/app/api/fetch.ts b/src/app/api/fetch.ts index d99cb8c..64b2b70 100644 --- a/src/app/api/fetch.ts +++ b/src/app/api/fetch.ts @@ -1,10 +1,10 @@ -import { serverUrl } from '@/lib/constants'; +import { bearerToken, serverUrl } from '@/lib/constants'; export const fetchAPI = async (endpoint: string) => { // Headers for authorization const options = { headers: { - Authorization: `Bearer ${process.env.NEXT_PUBLIC_BEARER_TOKEN}`, + Authorization: `Bearer ${bearerToken}`, }, }; diff --git a/src/lib/constants.ts b/src/lib/constants.ts index b67f611..3a08650 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,4 +1,5 @@ -const serverUrl = 'http://127.0.0.1:8081'; +const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL; +const bearerToken = process.env.NEXT_PUBLIC_BEARER_TOKEN; const sessionUrlParams = { 'Practice 1': 'fp1', @@ -19,6 +20,7 @@ const driverDefault = 'All Drivers'; const sessionDefault = 'Race'; export { + bearerToken, driverDefault, eventDefault, eventErrorMsg,