diff --git a/backend/core/settings.py b/backend/core/settings.py index ceb4882..d6b46a9 100644 --- a/backend/core/settings.py +++ b/backend/core/settings.py @@ -83,7 +83,7 @@ WSGI_APPLICATION = 'core.wsgi.application' DATABASES = { 'default': dj_database_url.config( - default=f"mysql://{config('DB_USER', default='user')}:{config('DB_PASSWORD', default='password')}@{config('DB_HOST', default='host')}:{config('DB_PORT', default='3306')}/{config('DB_NAME', default='name')}" + default=f"mysql://{config('MYSQL_USER', default='user')}:{config('MYSQL_PASSWORD', default='password')}@{config('MYSQL_HOST', default='host')}:{config('MYSQL_PORT', default='3306')}/{config('MYSQL_DATABASE', default='name')}" ) } @@ -125,8 +125,8 @@ STATIC_URL = 'static/' # CORS configuration CORS_ALLOWED_ORIGINS = [ - "http://localhost:5173", - "http://127.0.0.1:5173", + "http://localhost:1028", + "http://127.0.0.1:1028" ] # REST Framework & JWT settings diff --git a/frontend/src/api/axios.js b/frontend/src/api/axios.js index 28c9c04..dec3538 100644 --- a/frontend/src/api/axios.js +++ b/frontend/src/api/axios.js @@ -2,7 +2,7 @@ import axios from 'axios'; // Utiliser l'URL correcte pour le backend const api = axios.create({ - baseURL: '/api', + baseURL: import.meta.env.PROD ? '/api' : 'http://localhost:1029/api', }); // Ajouter un intercepteur pour gérer les erreurs de réseau diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 0fb3c7f..cd62e6a 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -4,6 +4,17 @@ import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], + server: { + proxy: { + '/api': { + target: 'http://localhost:1029', + changeOrigin: true, + secure: false, + rewrite: (path) => path.replace(/^\/api/, '/api') + } + } + }, + preview: { allowedHosts: [ 'boulangerie.louismazin.ovh' diff --git a/start.sh b/start.sh index fdc6d24..3288424 100644 --- a/start.sh +++ b/start.sh @@ -54,15 +54,13 @@ if [ ! -x "node_modules/.bin/vite" ]; then npm ci fi -export VITE_API_URL="/api" - echo "Build React..." npm run build echo "Démarrage frontend sur :1028" -npm run preview -- --host 0.0.0.0 --port 1028 & +npm run preview --host 0.0.0.0 --port 1028 & FRONTEND_PID=$! # --------------------------------------