diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 8d4857a8..996a71cc 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path +import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -50,16 +51,20 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', ] MIDDLEWARE.insert(0, 'corsheaders.middleware.CorsMiddleware') CORS_ALLOWED_ORIGINS = [ - "http://localhost:3000", + "volucy-gateway-e3d2bzbxdeaaayhz.westeurope-01.azurewebsites.net", ] CORS_ALLOW_CREDENTIALS = True +STATIC_URL = "/static/" +STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") ROOT_URLCONF = 'backend.urls' diff --git a/frontend/frontend/.env b/frontend/frontend/.env index 49ffa038..294190f6 100644 --- a/frontend/frontend/.env +++ b/frontend/frontend/.env @@ -1 +1 @@ -REACT_APP_API_URL=http://localhost:8000 +REACT_APP_API_URL=https://volucy-gateway-e3d2bzbxdeaaayhz.westeurope-01.azurewebsites.net diff --git a/frontend/frontend/src/api.js b/frontend/frontend/src/api.js new file mode 100644 index 00000000..4a6bc198 --- /dev/null +++ b/frontend/frontend/src/api.js @@ -0,0 +1,6 @@ +const API_URL = process.env.REACT_APP_API_URL; + +export const fetchData = async () => { + const response = await fetch(`${API_URL}/data/`); + return response.json(); +}; \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6e81c803..bfcd3f62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ -Flask -requests +Django +gunicorn +django-cors-headers +whitenoise openai diff --git a/start.sh b/start.sh new file mode 100644 index 00000000..e9b7dbc9 --- /dev/null +++ b/start.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Installiere Abhängigkeiten +cd backend +python -m venv venv +source venv/bin/activate +pip install -r requirements.txt + +# Migration durchführen +python manage.py migrate +python manage.py collectstatic --noinput + +# React bauen +cd ../frontend +npm install +npm run build + +# React-Frontend nach Django-Statisches-Verzeichnis verschieben +cp -r build/* ../backend/staticfiles/ + +# Starte Gunicorn (Django-Server) +cd ../backend +gunicorn backend.wsgi --bind 0.0.0.0:$PORT