From c03be28673fb87562e8af21a67b6fbf01501f4ae Mon Sep 17 00:00:00 2001 From: Leonardo Casales Date: Tue, 1 Mar 2022 14:22:09 -0300 Subject: [PATCH] fix: refresh token koa --- src/App/Presentation/Shared/Koa/AppKoa.ts | 5 ++++- src/Auth/Presentation/Handlers/Express/AuthHandler.ts | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/App/Presentation/Shared/Koa/AppKoa.ts b/src/App/Presentation/Shared/Koa/AppKoa.ts index a8e05fde..9dc22c4a 100644 --- a/src/App/Presentation/Shared/Koa/AppKoa.ts +++ b/src/App/Presentation/Shared/Koa/AppKoa.ts @@ -44,7 +44,10 @@ class AppKoa implements IApp public initConfig() { - this.app.use(cors()); + this.app.use(cors({ + credentials: true + })); + this.app.proxy = MainConfig.getInstance().getConfig().env === 'production'; this.app.use(helmet()); this.app.use(hbshbs.middleware({ viewPath: this.config.viewRouteEngine diff --git a/src/Auth/Presentation/Handlers/Express/AuthHandler.ts b/src/Auth/Presentation/Handlers/Express/AuthHandler.ts index 9a3a1210..bbd463dc 100644 --- a/src/Auth/Presentation/Handlers/Express/AuthHandler.ts +++ b/src/Auth/Presentation/Handlers/Express/AuthHandler.ts @@ -26,6 +26,7 @@ import RegisterRequest from '../../Requests/RegisterRequest'; import UpdateMeRequest from '../../Requests/UpdateMeRequest'; import VerifyYourAccountRequest from '../../Requests/VerifyYourAccountRequest'; import RefreshTokenMiddleware from '../../Middlewares/Express/RefreshTokenMiddleware'; +import MainConfig from '../../../../Config/mainConfig'; @controller('/api/auth') class AuthHandler @@ -68,6 +69,7 @@ class AuthHandler expires: moment.unix(payload.getExpires()).toDate(), maxAge: payload.getExpires(), path: '/api/auth/refresh-token', + secure: MainConfig.getInstance().getConfig().env === 'production', httpOnly: true }); @@ -108,6 +110,7 @@ class AuthHandler expires: moment.unix(payload.getExpires()).toDate(), maxAge: payload.getExpires(), path: '/api/auth/refresh-token', + secure: MainConfig.getInstance().getConfig().env === 'production', httpOnly: true });