fix: replace all hardcoded localhost URLs with env var in dashboard

All dashboard pages now use NEXT_PUBLIC_API_URL with localhost fallback
for local dev. Fixes tokens, volumes, storage, clusters, monitoring,
infrastructure, and usage pages for production deployment.
This commit is contained in:
2026-02-12 11:24:10 -08:00
parent 8edcaa614f
commit 6a3e6aa2d7
7 changed files with 23 additions and 14 deletions
+2 -1
View File
@@ -38,7 +38,8 @@ export default function TokensPage() {
setToken(null)
try {
const res = await fetch(`http://localhost:8000/v1/tokens/${chain}/metadata/${contract}`, {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
const res = await fetch(`${apiUrl}/v1/tokens/${chain}/metadata/${contract}`, {
headers: getAuthHeaders()
})
if (!res.ok) {
@@ -44,9 +44,11 @@ export default function ClustersPage() {
return {}
}
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
async function fetchClusters() {
try {
const res = await fetch("http://localhost:8000/v1/infra/clusters", {
const res = await fetch(`${apiUrl}/v1/infra/clusters`, {
headers: getAuthHeaders()
})
if (res.ok) {
@@ -70,7 +72,7 @@ export default function ClustersPage() {
if (!name.trim()) return
setCreating(true)
try {
const res = await fetch("http://localhost:8000/v1/infra/clusters", {
const res = await fetch(`${apiUrl}/v1/infra/clusters`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -99,7 +101,7 @@ export default function ClustersPage() {
async function downloadKubeconfig(clusterId: string) {
try {
const res = await fetch(`http://localhost:8000/v1/infra/clusters/${clusterId}/kubeconfig`, {
const res = await fetch(`${apiUrl}/v1/infra/clusters/${clusterId}/kubeconfig`, {
headers: getAuthHeaders()
})
if (res.ok) {
@@ -70,7 +70,8 @@ export default function MonitoringPage() {
useEffect(() => {
async function fetchMonitoring() {
try {
const res = await fetch("http://localhost:8000/v1/monitoring/nodes", {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
const res = await fetch(`${apiUrl}/v1/monitoring/nodes`, {
headers: getAuthHeaders(),
})
if (res.ok) {
+2 -1
View File
@@ -29,7 +29,8 @@ export default function InfrastructurePage() {
useEffect(() => {
async function fetchStats() {
try {
const res = await fetch("http://localhost:8000/v1/infra/stats", {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
const res = await fetch(`${apiUrl}/v1/infra/stats`, {
headers: getAuthHeaders()
})
if (res.ok) {
@@ -63,10 +63,11 @@ export default function StoragePage() {
async function fetchData() {
try {
const headers = getAuthHeaders()
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
const [volRes, snapRes, cloneRes] = await Promise.all([
fetch("http://localhost:8000/v1/infra/volumes", { headers }),
fetch("http://localhost:8000/v1/infra/snapshots", { headers }),
fetch("http://localhost:8000/v1/infra/clone", { headers }),
fetch(`${apiUrl}/v1/infra/volumes`, { headers }),
fetch(`${apiUrl}/v1/infra/snapshots`, { headers }),
fetch(`${apiUrl}/v1/infra/clone`, { headers }),
])
if (volRes.ok) setVolumes(await volRes.json())
@@ -87,7 +88,8 @@ export default function StoragePage() {
if (!cloneName.trim() || !sourceId) return
setCloning(true)
try {
const res = await fetch("http://localhost:8000/v1/infra/clone", {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
const res = await fetch(`${apiUrl}/v1/infra/clone`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -41,9 +41,11 @@ export default function VolumesPage() {
return {}
}
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"
async function fetchVolumes() {
try {
const res = await fetch("http://localhost:8000/v1/infra/volumes", {
const res = await fetch(`${apiUrl}/v1/infra/volumes`, {
headers: getAuthHeaders()
})
if (res.ok) {
@@ -67,7 +69,7 @@ export default function VolumesPage() {
if (!name.trim()) return
setCreating(true)
try {
const res = await fetch("http://localhost:8000/v1/infra/volumes", {
const res = await fetch(`${apiUrl}/v1/infra/volumes`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -95,7 +97,7 @@ export default function VolumesPage() {
async function createSnapshot(volumeId: string, volumeName: string) {
try {
const res = await fetch("http://localhost:8000/v1/infra/snapshots", {
const res = await fetch(`${apiUrl}/v1/infra/snapshots`, {
method: "POST",
headers: {
"Content-Type": "application/json",
+1 -1
View File
@@ -38,7 +38,7 @@ export default function UsagePage() {
<CardContent>
<Badge variant="default">Connected</Badge>
<p className="text-xs text-muted-foreground mt-1">
http://localhost:8000
{process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"}
</p>
</CardContent>
</Card>