Skip to content

Commit

Permalink
chore: add server url to .env
Browse files Browse the repository at this point in the history
  • Loading branch information
borolepratik committed May 4, 2024
1 parent 81d8541 commit 3ee2630
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"

NEXT_PUBLIC_BEARER_TOKEN="my-secret-token"
NEXT_PUBLIC_SERVER_URL="http://127.0.0.1:8081"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8
version: 9
run_install: true

- name: 🔬 Lint
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/fetch.ts
Original file line number Diff line number Diff line change
@@ -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}`,
},
};

Expand Down
4 changes: 3 additions & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -19,6 +20,7 @@ const driverDefault = 'All Drivers';
const sessionDefault = 'Race';

export {
bearerToken,
driverDefault,
eventDefault,
eventErrorMsg,
Expand Down

0 comments on commit 3ee2630

Please sign in to comment.