From 28b2a7ccd82241b3454bb660267d9f64eba7a8ac Mon Sep 17 00:00:00 2001 From: Nicolas Drolet Date: Tue, 5 Aug 2025 08:43:26 -0400 Subject: [PATCH] fix(login): add CORS permissions to main.ts, modify login route to include versioning --- docs/swagger/swagger-spec.json | 2 +- src/main.ts | 8 +++++++- src/modules/authentication/controllers/auth.controller.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 73f1761..7c3c888 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -1775,7 +1775,7 @@ ] } }, - "/auth/login": { + "/auth/v1/login": { "get": { "operationId": "AuthController_login", "parameters": [], diff --git a/src/main.ts b/src/main.ts index 4c9552d..264dc1e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,12 +31,18 @@ async function bootstrap() { rolling: true, cookie: { maxAge: 30 * 60 * 1000, - httpOnly: false, + httpOnly: true, } })) app.use(passport.initialize()); app.use(passport.session()); + // Enable CORS + app.enableCors({ + origin: 'http://localhost:9000', + credentials: true, + }); + //swagger config const config = new DocumentBuilder() .setTitle('Targo_Backend') diff --git a/src/modules/authentication/controllers/auth.controller.ts b/src/modules/authentication/controllers/auth.controller.ts index 687aea9..d3fbf12 100644 --- a/src/modules/authentication/controllers/auth.controller.ts +++ b/src/modules/authentication/controllers/auth.controller.ts @@ -6,12 +6,12 @@ import { Request, Response } from 'express'; export class AuthController { @UseGuards(OIDCLoginGuard) - @Get('/login') + @Get('/v1/login') login() {} @Get('/callback') @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { - res.redirect('/'); + res.redirect('http://localhost:9000/#/login-success'); } }