From 4bbdcc1687263fdc6645ef5dd5adbc14b0a008cb Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 28 Apr 2023 20:09:19 -0400 Subject: [PATCH] fix(striker-ui-api): enable credentials in cors middleware --- striker-ui-api/src/app.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/striker-ui-api/src/app.ts b/striker-ui-api/src/app.ts index c50193ca..39773fab 100644 --- a/striker-ui-api/src/app.ts +++ b/striker-ui-api/src/app.ts @@ -6,13 +6,23 @@ import passport from './passport'; import routes from './routes'; import { rrouters } from './lib/rrouters'; import session from './session'; +import { stdout } from './lib/shell'; export default (async () => { const app = express(); app.use(json()); - app.use(cors()); + app.use( + cors({ + origin: (requestOrigin, done) => { + stdout(`Request header: Origin=${requestOrigin}`); + + done(null, requestOrigin); + }, + credentials: true, + }), + ); // Add session handler to the chain **after** adding other handlers that do // not depend on session(s).