Fix frontend unable to load weather data by using relative API URL

NEXT_PUBLIC_API_URL was only set at runtime via k8s ConfigMap, but Next.js
inlines NEXT_PUBLIC_* vars at build time. The fallback localhost:8080 URL was
baked into the JS bundle, causing all browser requests to fail. Changed default
to relative /api/v1 which routes correctly through the Ingress. Also updates
Dockerfile ENV syntax and k8s frontend port to 8080.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Hatlen
2026-02-05 23:59:31 -08:00
parent 1f0e678d47
commit 88787b2eb1
4 changed files with 37 additions and 13 deletions

View File

@@ -13,8 +13,8 @@ COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
# Set production environment # Set production environment
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV production ENV NODE_ENV=production
RUN npm run build RUN npm run build
@@ -22,8 +22,8 @@ RUN npm run build
FROM node:20-alpine AS runner FROM node:20-alpine AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
@@ -42,8 +42,8 @@ USER nextjs
EXPOSE 3000 EXPOSE 3000
ENV PORT 3000 ENV PORT=3000
ENV HOSTNAME "0.0.0.0" ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"] CMD ["node", "server.js"]

View File

@@ -7,7 +7,7 @@ import {
APIError, APIError,
} from './types' } from './types'
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080/api/v1' const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || '/api/v1'
class APIClient { class APIClient {
private baseURL: string private baseURL: string

0
frontend/public/.gitkeep Normal file
View File

View File

@@ -4,6 +4,30 @@ kind: Namespace
metadata: metadata:
name: paragliding name: paragliding
---
# External PostgreSQL Service (points to host database)
apiVersion: v1
kind: Service
metadata:
name: postgres-service
namespace: paragliding
spec:
ports:
- port: 5432
targetPort: 5432
---
apiVersion: v1
kind: Endpoints
metadata:
name: postgres-service
namespace: paragliding
subsets:
- addresses:
- ip: 192.168.1.93
ports:
- port: 5432
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@@ -106,7 +130,7 @@ spec:
image: harbor.scottyah.com/scottyah/paragliding-web:latest image: harbor.scottyah.com/scottyah/paragliding-web:latest
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 3000 - containerPort: 8080
envFrom: envFrom:
- configMapRef: - configMapRef:
name: paragliding-config name: paragliding-config
@@ -120,13 +144,13 @@ spec:
livenessProbe: livenessProbe:
httpGet: httpGet:
path: / path: /
port: 3000 port: 8080
initialDelaySeconds: 10 initialDelaySeconds: 10
periodSeconds: 30 periodSeconds: 30
readinessProbe: readinessProbe:
httpGet: httpGet:
path: / path: /
port: 3000 port: 8080
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 10 periodSeconds: 10
imagePullSecrets: imagePullSecrets:
@@ -140,8 +164,8 @@ metadata:
namespace: paragliding namespace: paragliding
spec: spec:
ports: ports:
- port: 3000 - port: 8080
targetPort: 3000 targetPort: 8080
protocol: TCP protocol: TCP
selector: selector:
app: paragliding-web app: paragliding-web
@@ -179,4 +203,4 @@ spec:
service: service:
name: paragliding-web-svc name: paragliding-web-svc
port: port:
number: 3000 number: 8080