From 0b86cd49cfdf6f47976599d1f04446205ef844ca Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Mon, 26 May 2025 17:44:23 -0400 Subject: [PATCH] Update API to env var --- makefile | 1 + src/components/BotsManagement.tsx | 2 +- src/components/IndividualClientPage.tsx | 1 - src/components/SystemsManagement.tsx | 2 +- src/constants/api.ts | 2 +- src/context/AuthContext.tsx | 2 +- src/utils/AuthAwareFetch.ts | 4 ++-- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/makefile b/makefile index 5bfb2a7..efe3ad7 100644 --- a/makefile +++ b/makefile @@ -57,6 +57,7 @@ docker-dev: #docker-build --rm \ --name $(DOCKER_DEV_CONTAINER_NAME) \ -p 3000:3000 \ + -e NEXT_PUBLIC_DRB_BASE_API_URL=$(NEXT_PUBLIC_DRB_BASE_API_URL) \ -v "$(PWD):/app" \ -v "/app/node_modules" \ -e NODE_ENV=development \ diff --git a/src/components/BotsManagement.tsx b/src/components/BotsManagement.tsx index d5e8f66..4fe0b56 100644 --- a/src/components/BotsManagement.tsx +++ b/src/components/BotsManagement.tsx @@ -10,7 +10,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Checkbox } from '@/components/ui/checkbox'; -import { API_BASE_URL } from '@/constants/api'; +import { DRB_BASE_API_URL } from '@/constants/api'; import { DiscordId, System, ErrorResponse } from '@/types'; import { authAwareFetch } from '@/utils/AuthAwareFetch'; diff --git a/src/components/IndividualClientPage.tsx b/src/components/IndividualClientPage.tsx index 37f707b..1e0ab8b 100644 --- a/src/components/IndividualClientPage.tsx +++ b/src/components/IndividualClientPage.tsx @@ -3,7 +3,6 @@ import React, { useState, useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'; -import { API_BASE_URL } from '@/constants/api'; import { ErrorResponse, NodeStatusResponse, System } from '@/types'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; diff --git a/src/components/SystemsManagement.tsx b/src/components/SystemsManagement.tsx index 6afccbb..bda07fb 100644 --- a/src/components/SystemsManagement.tsx +++ b/src/components/SystemsManagement.tsx @@ -9,7 +9,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; import { Textarea } from '@/components/ui/textarea'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; -import { API_BASE_URL } from '@/constants/api'; +import { DRB_BASE_API_URL } from '@/constants/api'; import { DemodTypes, TalkgroupTag, System, ErrorResponse } from '@/types'; import { authAwareFetch } from '@/utils/AuthAwareFetch'; diff --git a/src/constants/api.ts b/src/constants/api.ts index 026c587..783f833 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -1 +1 @@ -export const API_BASE_URL = "http://172.16.100.81:5000"; \ No newline at end of file +export const DRB_BASE_API_URL: string = process.env.NEXT_PUBLIC_DRB_BASE_API_URL || "http://172.16.100.81:9000"; \ No newline at end of file diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index 58525ea..3615f63 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -8,7 +8,7 @@ import React, { ReactNode, useCallback } from 'react'; -import { API_BASE_URL } from '@/constants/api'; // Assuming you have this +import { DRB_BASE_API_URL } from '@/constants/api'; // Assuming you have this import { authAwareFetch } from '@/utils/AuthAwareFetch'; // Import authAwareFetch // Define your User and UserRoles types if not already in types.ts diff --git a/src/utils/AuthAwareFetch.ts b/src/utils/AuthAwareFetch.ts index bf6544f..f0b9d71 100644 --- a/src/utils/AuthAwareFetch.ts +++ b/src/utils/AuthAwareFetch.ts @@ -1,5 +1,5 @@ // utils/AuthAwareFetch.ts -import { API_BASE_URL } from '@/constants/api'; // Make sure this path is correct +import { DRB_BASE_API_URL } from '@/constants/api'; // Make sure this path is correct interface AuthAwareFetchOptions extends RequestInit { token?: string; @@ -20,7 +20,7 @@ export const authAwareFetch = async ( console.log(requestHeaders, rest, url) - const response = await fetch(`${API_BASE_URL}${url}`, { + const response = await fetch(`${DRB_BASE_API_URL}${url}`, { headers: requestHeaders, ...rest, });