Merge pull request 'example frontend-backend communication' (#37) from backend_complete into main

Reviewed-on: #37
This commit was merged in pull request #37.
This commit is contained in:
2025-09-24 18:21:05 +00:00
12 changed files with 405 additions and 26 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ app.use(loggingService.requestLoggingMiddleware());
app.use((req, res, next) => {
const origin = req.headers.origin;
const allowedOrigins = ['http://localhost:3000', 'http://localhost:3001', 'http://localhost:8080'];
const allowedOrigins = ['http://localhost:3000', 'http://localhost:3001', 'http://localhost:8080', process.env.FRONTEND_URL];
if (!origin || allowedOrigins.includes(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin || '*');
@@ -29,7 +29,7 @@ userRouter.post('/login',
const result = await container.loginCommandHandler.execute({ username, password }, res);
if (result) {
logAuth('User login successful', result.user.id, { username: result.user.username }, req, res);
logAuth('User login successful', undefined, { username: result.user.username }, req, res);
res.json(result);
} else {
throw new Error(`Login failed: ${result}`);
@@ -80,7 +80,6 @@ userRouter.post('/create',
const result = await container.createUserCommandHandler.execute(req.body);
logRequest('User created successfully', req, res, {
userId: result.id,
username: result.username
});