Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,6 @@ EVENT_ORG_LISTENER_URLS='http://interface:3567/mentoring/v1/organization/eventLi
EVENT_ENABLE_ORG_EVENTS=true
#Generic Email template for new users
GENERIC_INVITATION_EMAIL_TEMPLATE_CODE=generic_invite

# Allowed host by CORS
ALLOWED_HOST = "http://examplDomain.com"
6 changes: 6 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ app.use(bodyParser.json({ limit: '50MB' }))

app.use(express.static('public'))

// Middleware to set Access-Control-Allow-Origin header
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', process.env.ALLOWED_HOST)
next()
})

/* Logs request info if environment is configured to enable log */
app.all('*', (req, res, next) => {
logger.info('***User Service Request Log***', {
Expand Down
5 changes: 5 additions & 0 deletions src/envVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ let enviromentVariables = {
optional: true,
default: 'generic_invite',
},
ALLOWED_HOST: {
message: 'Required CORS allowed host',
optional: true,
default: '*',
},
}

let success = true
Expand Down