diff --git a/docker-compose.yml b/docker-compose.yml index f333cb9..0ff1090 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,15 @@ -version: '3.8' - +version: "3.9" services: - backend: - build: - context: ./backend - container_name: schiri-backend - ports: - - "3000:3000" - restart: unless-stopped - frontend: - build: - context: ./frontend - container_name: schiri-frontend + build: ./frontend + container_name: frontend ports: - - "5001:80" - restart: unless-stopped + - "5001:80" depends_on: - backend + + backend: + build: ./backend + container_name: backend + expose: + - "3000" diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 75e6e03..fe6e822 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -5,21 +5,25 @@ server { root /usr/share/nginx/html; index index.html; + # App-Route location / { try_files $uri /index.html; } + # API → Intern weiterleiten an Express + location /api/ { + proxy_pass http://backend:3000/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + + # Static Files location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|ttf|svg|eot|otf)$ { expires 6M; access_log off; add_header Cache-Control "public"; } - - location /api/ { - proxy_pass http://backend:3000; - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - } } - diff --git a/frontend/src/pages/QuizPage.jsx b/frontend/src/pages/QuizPage.jsx index a2a1ef3..f01fcbf 100644 --- a/frontend/src/pages/QuizPage.jsx +++ b/frontend/src/pages/QuizPage.jsx @@ -12,10 +12,6 @@ export default function QuizPage({ mode, onBack, customQuestions }) { const [answerStatus, setAnswerStatus] = useState([]); // "correct" | "wrong" | undefined - //API BAse - const API_BASE = "https://api.schiri.marc-wieland.de"; // oder dein Backend-Service - - useEffect(() => { const savedQuestions = sessionStorage.getItem("quiz_questions"); const savedIndex = sessionStorage.getItem("quiz_current_idx"); @@ -23,6 +19,8 @@ useEffect(() => { const savedWrong = sessionStorage.getItem("quiz_wrong_questions"); const savedStatus = sessionStorage.getItem("quiz_answer_status"); + + if (savedQuestions) { setQuestions(JSON.parse(savedQuestions)); setCurrentIdx(parseInt(savedIndex) || 0); @@ -36,7 +34,7 @@ useEffect(() => { setQuestions(customQuestions); sessionStorage.setItem("quiz_questions", JSON.stringify(customQuestions)); } else { - fetch(`${API_BASE}/api/questions/${mode}`) + fetch(`/api/questions/${mode}`) .then((res) => res.json()) .then((data) => { const shuffled = data.sort(() => 0.5 - Math.random()).slice(0, 30);