From e333a54025ee5257205420ede3d11764c213b0cc Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 4 Feb 2026 12:02:14 +0100 Subject: [PATCH] feat(api): refactor API client usage across frontend components - Replaced direct axios calls with a centralized apiClient in Register, Login, and Activate components for improved maintainability and consistency. - Updated backend base URL logic to support different environments, enhancing flexibility in API interactions. - Added console logging in the authController for better tracking of user registration flow. --- backend/controllers/authController.js | 3 +++ frontend/src/apiClient.js | 3 ++- frontend/src/views/Activate.vue | 4 ++-- frontend/src/views/Login.vue | 6 +++--- frontend/src/views/Register.vue | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/controllers/authController.js b/backend/controllers/authController.js index e4a7c51..4fabb7a 100644 --- a/backend/controllers/authController.js +++ b/backend/controllers/authController.js @@ -3,9 +3,12 @@ import { register, activateUser, login, logout } from '../services/authService.j const registerUser = async (req, res, next) => { try { const { email, password } = req.body; + console.log('registerUser', email, password); await register(email, password); + console.log('registerUser done'); // Aus Sicherheitsgründen KEINE Userdaten (Passwort-Hash, Aktivierungscode, ...) zurückgeben res.status(201).json({ success: true }); + console.log('registerUser response sent'); } catch (error) { next(error); } diff --git a/frontend/src/apiClient.js b/frontend/src/apiClient.js index c29713e..830724b 100644 --- a/frontend/src/apiClient.js +++ b/frontend/src/apiClient.js @@ -1,7 +1,8 @@ import axios from 'axios'; import store from './store'; -export const backendBaseUrl = import.meta.env.VITE_BACKEND || 'http://localhost:3005'; +export const backendBaseUrl = import.meta.env.VITE_BACKEND + || (import.meta.env.DEV ? 'http://localhost:3005' : window.location.origin); const apiClient = axios.create({ baseURL: `${backendBaseUrl}/api`, diff --git a/frontend/src/views/Activate.vue b/frontend/src/views/Activate.vue index 31bf58d..45cba40 100644 --- a/frontend/src/views/Activate.vue +++ b/frontend/src/views/Activate.vue @@ -27,7 +27,7 @@