i am trying to deploy an app on Kubernetes pods locally on minikubes. i am having trouble with nordport and accessing my frontend
i added this to config.js of my react app
window.RUNTIME_CONFIG = {
BACKEND_URL: "${BACKEND_URL}"
};
and am using it in the app like so
const x = window.RUNTIME_CONFIG.BACKEND_URL;
i also have an entrypoint.sh
#!/bin/sh
set -e
if [ -f /usr/share/nginx/html/config.js ]; then
envsubst '${BACKEND_URL}' < /usr/share/nginx/html/config.js > /tmp/config.js
mv /tmp/config.js /usr/share/nginx/html/config.js
fi
exec nginx -g 'daemon off;'
and this is my dockerfile
# build
FROM node:18.19.1 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# runtime
FROM nginx:alpine
# install envsubst
RUN apk add --no-cache gettext
COPY --from=build /app/build /usr/share/nginx/html
COPY public/config.js /usr/share/nginx/html/config.js
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 80
CMD ["/entrypoint.sh"]
to enable cors in the backend i have a set a list of allowed ips
var allowedOrigins = map[string]bool{
"http://localhost:3000": true,
"http://localhost:30100": true,
os.Getenv("CLIENT_IP"): true,
"http://:30100": true,
"http://app-service:3000": true,
}
these are the ports in my frontend service
ports:
- protocol: TCP
port: 3000
targetPort: 80
nodePort: 30100
and i have env variable in my frontend deployment
env:
- name: BACKEND_URL
value: http://server-service:8081
but i nothing is showing up on