From 6d98f23bd0e3d098a897268a7e738a727e21b6b7 Mon Sep 17 00:00:00 2001 From: "Grayson, Matthew" Date: Wed, 28 Feb 2024 13:41:58 -0600 Subject: [PATCH 1/2] Revert cors option access-control-allow-origin. --- backend/src/api/app.ts | 10 +--------- frontend/scripts/constants.js | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/backend/src/api/app.ts b/backend/src/api/app.ts index 980fee1a3..3d17c4c68 100644 --- a/backend/src/api/app.ts +++ b/backend/src/api/app.ts @@ -61,15 +61,7 @@ app.use(express.json({ strict: false })); app.use( cors({ - origin: [ - 'api.staging-cd.crossfeed.cyber.dhs.gov', - 'api.crossfeed.cyber.dhs.gov', - 'api.staging.crossfeed.cyber.dhs.gov', - 'crossfeed.cyber.dhs.gov', - 'staging.crossfeed.cyber.dhs.gov', - 'staging-cd.crossfeed.cyber.dhs.gov', - /localhost$/ - ], + origin: [/.*crossfeed\.cyber\.dhs\.gov$/, /localhost$/], methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'] }) ); diff --git a/frontend/scripts/constants.js b/frontend/scripts/constants.js index aa5162f3d..7579df589 100644 --- a/frontend/scripts/constants.js +++ b/frontend/scripts/constants.js @@ -1,11 +1,3 @@ //CORS Options -export const ALLOW_ORIGIN = [ - 'api.staging-cd.crossfeed.cyber.dhs.gov', - 'api.crossfeed.cyber.dhs.gov', - 'api.staging.crossfeed.cyber.dhs.gov', - 'crossfeed.cyber.dhs.gov', - 'staging.crossfeed.cyber.dhs.gov', - 'staging-cd.crossfeed.cyber.dhs.gov', - /localhost$/ -]; +export const ALLOW_ORIGIN = [/.*crossfeed\.cyber\.dhs\.gov$/, /localhost$/]; export const ALLOW_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']; From f7af61130af978611cef08583019d2e837326aaa Mon Sep 17 00:00:00 2001 From: "Grayson, Matthew" Date: Wed, 28 Feb 2024 13:46:51 -0600 Subject: [PATCH 2/2] Add console logs to list organizations endpoint. --- backend/src/api/organizations.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/api/organizations.ts b/backend/src/api/organizations.ts index a0a785bc9..cbae68f2e 100644 --- a/backend/src/api/organizations.ts +++ b/backend/src/api/organizations.ts @@ -367,6 +367,8 @@ export const create = wrapHandler(async (event) => { * - Organizations */ export const list = wrapHandler(async (event) => { + console.log('list function called with event: ', event); + if (!isGlobalViewAdmin(event) && getOrgMemberships(event).length === 0) { return { //TODO: Should we return a 403? @@ -375,6 +377,8 @@ export const list = wrapHandler(async (event) => { }; } await connectToDatabase(); + console.log('Database connected'); + let where: any = { parent: null }; if (!isGlobalViewAdmin(event)) { where = { id: In(getOrgMemberships(event)), parent: null }; @@ -385,6 +389,8 @@ export const list = wrapHandler(async (event) => { order: { name: 'ASC' } }); + console.log('Organization.find result: ', result); + return { statusCode: 200, body: JSON.stringify(result)