Neue Version

This commit is contained in:
MarcWieland 2025-07-25 01:49:35 +02:00
parent ac5070d059
commit 49820a3665
3 changed files with 25 additions and 28 deletions

View File

@ -1,20 +1,15 @@
version: '3.8' version: "3.9"
services: services:
backend:
build:
context: ./backend
container_name: schiri-backend
ports:
- "3000:3000"
restart: unless-stopped
frontend: frontend:
build: build: ./frontend
context: ./frontend container_name: frontend
container_name: schiri-frontend
ports: ports:
- "5001:80" - "5001:80"
restart: unless-stopped
depends_on: depends_on:
- backend - backend
backend:
build: ./backend
container_name: backend
expose:
- "3000"

View File

@ -5,21 +5,25 @@ server {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html; index index.html;
# App-Route
location / { location / {
try_files $uri /index.html; 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)$ { location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|ttf|svg|eot|otf)$ {
expires 6M; expires 6M;
access_log off; access_log off;
add_header Cache-Control "public"; 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;
}
} }

View File

@ -12,10 +12,6 @@ export default function QuizPage({ mode, onBack, customQuestions }) {
const [answerStatus, setAnswerStatus] = useState([]); // "correct" | "wrong" | undefined const [answerStatus, setAnswerStatus] = useState([]); // "correct" | "wrong" | undefined
//API BAse
const API_BASE = "https://api.schiri.marc-wieland.de"; // oder dein Backend-Service
useEffect(() => { useEffect(() => {
const savedQuestions = sessionStorage.getItem("quiz_questions"); const savedQuestions = sessionStorage.getItem("quiz_questions");
const savedIndex = sessionStorage.getItem("quiz_current_idx"); const savedIndex = sessionStorage.getItem("quiz_current_idx");
@ -23,6 +19,8 @@ useEffect(() => {
const savedWrong = sessionStorage.getItem("quiz_wrong_questions"); const savedWrong = sessionStorage.getItem("quiz_wrong_questions");
const savedStatus = sessionStorage.getItem("quiz_answer_status"); const savedStatus = sessionStorage.getItem("quiz_answer_status");
if (savedQuestions) { if (savedQuestions) {
setQuestions(JSON.parse(savedQuestions)); setQuestions(JSON.parse(savedQuestions));
setCurrentIdx(parseInt(savedIndex) || 0); setCurrentIdx(parseInt(savedIndex) || 0);
@ -36,7 +34,7 @@ useEffect(() => {
setQuestions(customQuestions); setQuestions(customQuestions);
sessionStorage.setItem("quiz_questions", JSON.stringify(customQuestions)); sessionStorage.setItem("quiz_questions", JSON.stringify(customQuestions));
} else { } else {
fetch(`${API_BASE}/api/questions/${mode}`) fetch(`/api/questions/${mode}`)
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { .then((data) => {
const shuffled = data.sort(() => 0.5 - Math.random()).slice(0, 30); const shuffled = data.sort(() => 0.5 - Math.random()).slice(0, 30);