diff --git a/backend/__pycache__/main.cpython-313.pyc b/backend/__pycache__/main.cpython-313.pyc index 6f41891..94945cc 100644 Binary files a/backend/__pycache__/main.cpython-313.pyc and b/backend/__pycache__/main.cpython-313.pyc differ diff --git a/backend/main.py b/backend/main.py index 01171c9..773cccc 100644 --- a/backend/main.py +++ b/backend/main.py @@ -14,7 +14,6 @@ router = APIRouter() app.add_middleware( CORSMiddleware, allow_origins=["*"], - allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) diff --git a/frontend/10-generate-env.sh b/frontend/10-generate-env.sh new file mode 100644 index 0000000..173aa69 --- /dev/null +++ b/frontend/10-generate-env.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Generate env.js from the template +envsubst < /etc/env/env.js.template > /usr/share/nginx/html/env.js diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 02ba70e..9f5a53f 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,29 +1,29 @@ -# Stage 1: Build -FROM node:20-alpine AS builder +# Stage 1: Build the frontend +FROM node:20 AS builder + WORKDIR /app -COPY package*.json ./ -RUN npm install --legacy-peer-deps COPY . . +RUN npm install RUN npm run build -# Stage 2: Runtime (NGINX) +# Stage 2: Serve with nginx FROM nginx:alpine -# Install dos2unix to fix Windows line endings +# Install dos2unix RUN apk add --no-cache dos2unix -# Clean default nginx html -RUN rm -rf /usr/share/nginx/html/* - -# Copy built frontend +# Copy built app COPY --from=builder /app/dist /usr/share/nginx/html -# Copy entrypoint and normalize line endings -COPY docker-entrypoint.sh /docker-entrypoint.sh -RUN dos2unix /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh +# ✅ Copy env.js.template +COPY public/env.js.template /etc/env/env.js.template -# Fallback env.js (to avoid 404 before initContainer writes real one) -RUN echo "window.env = {}" > /usr/share/nginx/html/env.js +# ✅ Copy nginx config +COPY nginx.conf /etc/nginx/conf.d/default.conf -# Set entrypoint -ENTRYPOINT ["/docker-entrypoint.sh"] +# ✅ Add env generator script to nginx entrypoint hook +COPY 10-generate-env.sh /docker-entrypoint.d/10-generate-env.sh +RUN dos2unix /docker-entrypoint.d/10-generate-env.sh && chmod +x /docker-entrypoint.d/10-generate-env.sh + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/frontend/docker-entrypoint.sh b/frontend/docker-entrypoint.sh deleted file mode 100644 index 6fab1ad..0000000 --- a/frontend/docker-entrypoint.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -set -e - -# Generate env.js at runtime from env var -cat < /usr/share/nginx/html/env.js -window.env = { - VITE_API_URL: "${VITE_API_URL}" -}; -EOF - -exec nginx -g "daemon off;" diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js index 309ad6a..c483f9c 100644 --- a/frontend/src/services/api.js +++ b/frontend/src/services/api.js @@ -1,4 +1,4 @@ -const API_BASE = window?.env?.VITE_API_URL || '/api'; +const API_BASE = window?.ENV?.API_BASE || ""; export async function fetchSections() { const res = await fetch(`${API_BASE}/apps`); diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 0466183..0c137ac 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -1,6 +1,59 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], }); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// export default defineConfig({ +// plugins: [react()], +// server: { +// proxy: { +// '/apps': 'http://localhost:8000', +// '/add_app': 'http://localhost:8000', +// '/icon': 'http://localhost:8000', +// } +// } +// }); + + + + + +// import { defineConfig } from 'vite'; +// import react from '@vitejs/plugin-react'; + +// export default defineConfig({ +// plugins: [react()], +// });