From b1e378393078fc3b2e7b6122d1cd60ed23999b65 Mon Sep 17 00:00:00 2001 From: Chirag-amiti Date: Mon, 30 Mar 2026 00:23:17 +0530 Subject: [PATCH] Fix Azure frontend API base URL and prevent empty env fallback --- .../azure-static-web-apps-witty-bay-0a34d3100.yml | 12 +++++++----- frontend/src/features/reports/ReportsPage.tsx | 4 +++- frontend/src/services/api/client.ts | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-witty-bay-0a34d3100.yml b/.github/workflows/azure-static-web-apps-witty-bay-0a34d3100.yml index e4d94b7..c31c730 100644 --- a/.github/workflows/azure-static-web-apps-witty-bay-0a34d3100.yml +++ b/.github/workflows/azure-static-web-apps-witty-bay-0a34d3100.yml @@ -19,11 +19,13 @@ jobs: with: submodules: true lfs: false - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WITTY_BAY_0A34D3100 }} + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + env: + VITE_API_BASE_URL: https://trackmint-api-chirag-ejakfzdadqhmfrhv.southindia-01.azurewebsites.net/api + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WITTY_BAY_0A34D3100 }} repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### diff --git a/frontend/src/features/reports/ReportsPage.tsx b/frontend/src/features/reports/ReportsPage.tsx index bdf8231..4712aee 100644 --- a/frontend/src/features/reports/ReportsPage.tsx +++ b/frontend/src/features/reports/ReportsPage.tsx @@ -85,7 +85,9 @@ export function ReportsPage() { if (params.categoryId) search.set("categoryId", params.categoryId); if (params.type) search.set("type", params.type); - const response = await fetch(`${import.meta.env.VITE_API_BASE_URL ?? "http://localhost:5151/api"}/reports/export/csv?${search.toString()}`, { + const configuredApiBaseUrl = import.meta.env.VITE_API_BASE_URL?.trim(); + const apiBaseUrl = configuredApiBaseUrl && configuredApiBaseUrl.length > 0 ? configuredApiBaseUrl : "http://localhost:5151/api"; + const response = await fetch(`${apiBaseUrl}/reports/export/csv?${search.toString()}`, { headers: { Authorization: `Bearer ${session?.accessToken ?? ""}`, }, diff --git a/frontend/src/services/api/client.ts b/frontend/src/services/api/client.ts index 0432ed5..cbb3685 100644 --- a/frontend/src/services/api/client.ts +++ b/frontend/src/services/api/client.ts @@ -2,7 +2,8 @@ import axios from "axios"; import type { AuthResponse } from "../../types/models"; import { getAuthSession, useAuthStore } from "../../store/auth-store"; -const baseURL = import.meta.env.VITE_API_BASE_URL ?? "http://localhost:5151/api"; +const configuredApiBaseUrl = import.meta.env.VITE_API_BASE_URL?.trim(); +const baseURL = configuredApiBaseUrl && configuredApiBaseUrl.length > 0 ? configuredApiBaseUrl : "http://localhost:5151/api"; export const api = axios.create({ baseURL,