Update dynamic values

This commit is contained in:
dvirlabs 2025-12-23 21:27:42 +02:00
parent 894b4296c4
commit 67d217ca12
5 changed files with 9 additions and 2 deletions

2
.gitignore vendored
View File

@ -27,4 +27,4 @@ env/
Thumbs.db
my-recipes-chart/\
helm/
ipify-chart/

1
frontend/.env.example Normal file
View File

@ -0,0 +1 @@
VITE_API_URL=http://localhost:8000

View File

@ -24,6 +24,11 @@ COPY --from=build /app/dist /usr/share/nginx/html
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Create entrypoint script to inject env variables
RUN echo '#!/bin/sh' > /docker-entrypoint.d/40-generate-env.sh && \
echo 'echo "window.ENV = { VITE_API_URL: \"${VITE_API_URL}\" };" > /usr/share/nginx/html/env.js' >> /docker-entrypoint.d/40-generate-env.sh && \
chmod +x /docker-entrypoint.d/40-generate-env.sh
# Expose port
EXPOSE 80

View File

@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>IP Subnet Calculator</title>
<script src="/env.js"></script>
</head>
<body>
<div id="root"></div>

View File

@ -2,7 +2,7 @@ import { useState } from 'react'
import axios from 'axios'
import './App.css'
const API_URL = 'http://localhost:8000'
const API_URL = window.ENV?.VITE_API_URL || 'http://localhost:8000'
function App() {
const [ipAddress, setIpAddress] = useState('')