Skip to content
Snippets Groups Projects
Commit 92c93408 authored by Xiao Gui's avatar Xiao Gui
Browse files

bugfix: homogenize host_pathname definition in line with okd

parent 33ba1a04
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,11 @@ const { configureAuth } = require('./oidc')
const jwtDecode = require('jwt-decode')
const HOSTNAME = process.env.HOSTNAME || 'http://localhost:3000'
const HOST_PATHNAME = process.env.HOST_PATHNAME || ''
const clientId = process.env.HBP_CLIENTID || 'no hbp id'
const clientSecret = process.env.HBP_CLIENTSECRET || 'no hbp client secret'
const discoveryUrl = 'https://services.humanbrainproject.eu/oidc'
const redirectUri = `${HOSTNAME}/hbp-oidc/cb`
const redirectUri = `${HOSTNAME}${HOST_PATHNAME}/hbp-oidc/cb`
let REFRESH_TOKEN = process.env.REFRESH_TOKEN || null
const CLIENT_NOT_INIT = `Client is not initialised.`
......
......@@ -6,6 +6,7 @@ const DISABLE_JUBRAIN_PMAP = process.env.DISABLE_JUBRAIN_PMAP
const DISABLE_JUBRAIN_PMAP_V17 = process.env.DISABLE_JUBRAIN_PMAP_V17
const DISABLE_DWM_PMAP = process.env.DISABLE_DWM_PMAP
const HOSTNAME = process.env.HOSTNAME || 'http://localhost:3000'
const HOST_PATHNAME = process.env.HOST_PATHNAME || ''
let previewMap = new Map(),
previewMapKeySet = new Set()
......@@ -48,7 +49,7 @@ exports.getPreviewFile = ({ datasetName, templateSelected }) => previewMap.get(d
...file,
...(file.url && !/^http/.test(file.url)
? {
url: `${HOSTNAME}/${file.url}`
url: `${HOSTNAME}${HOST_PATHNAME}/${file.url}`
}
: {})
}
......
......@@ -66,6 +66,11 @@ const PORT = process.env.PORT || 3000
// n.b. no trailing slash is important
const HOST_PATHNAME = process.env.HOST_PATHNAME || ''
if(HOST_PATHNAME !== '') {
if (HOST_PATHNAME.slice(0,1) !== '/') throw new Error(`HOST_PATHNAME, if defined and non-empty, should start with a leading slash. HOST_PATHNAME: ${HOST_PATHNAME}`)
if (HOST_PATHNAME.slice(-1) === '/') throw new Error(`HOST_PATHNAME, if defined and non-emtpy, should NOT end with a slash. HOST_PATHNAME: ${HOST_PATHNAME}`)
}
server.disable('x-powered-by')
server.use(HOST_PATHNAME, app)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment