Update dynamic values
This commit is contained in:
parent
894b4296c4
commit
67d217ca12
2
.gitignore
vendored
2
.gitignore
vendored
@ -27,4 +27,4 @@ env/
|
||||
Thumbs.db
|
||||
|
||||
my-recipes-chart/\
|
||||
helm/
|
||||
ipify-chart/
|
||||
1
frontend/.env.example
Normal file
1
frontend/.env.example
Normal file
@ -0,0 +1 @@
|
||||
VITE_API_URL=http://localhost:8000
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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('')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user