diff --git a/frontend/.env.example b/frontend/.env.example new file mode 100644 index 0000000..1406906 --- /dev/null +++ b/frontend/.env.example @@ -0,0 +1,4 @@ +# Backend API base URL +# Override for deployed/staging environments (e.g., PythonAnywhere). +# Defaults to http://127.0.0.1:5000/ for local development. +NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:5000/ diff --git a/frontend/.gitignore b/frontend/.gitignore index 5ef6a52..3957fb3 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -31,7 +31,11 @@ yarn-error.log* .pnpm-debug.log* # env files (can opt-in for committing if needed) -.env* +.env.example +.env.local +.env.development +.env.production +.env # vercel .vercel diff --git a/frontend/services/api.ts b/frontend/services/api.ts index 006d226..7244e38 100644 --- a/frontend/services/api.ts +++ b/frontend/services/api.ts @@ -5,7 +5,8 @@ import { SDGClassificationResponse, } from "@/types/main"; -const API_BASE_URL = "http://127.0.0.1:5000/"; +const API_BASE_URL = + process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://127.0.0.1:5000/"; const apiClient = axios.create({ baseURL: API_BASE_URL,