Fixed route changes not using getUrl causing invalid url to be used when

using pathPrefix, renamed basePath to prefixPath, updated how getUrl
gets the prefixPath to prevent the need for rebuilding when its changed
now just requires restart
This commit is contained in:
JJ Kasper
2018-06-01 20:56:02 -05:00
parent 017a9993ee
commit e35f6f74eb
12 changed files with 80 additions and 54 deletions

View File

@@ -1,15 +1,18 @@
const url = require('url')
const urljoin = require('url-join')
const basePath = require('./basePath')
const { host, port, protocol } = require('../config/host.json')
module.exports = (path, absolute) => {
path = urljoin(basePath, path)
const { pathPrefix } =
typeof window === 'undefined' ? app.get('kbConf') : window.kbConf
path = urljoin(pathPrefix, path)
if (!absolute) return path
// absolute should only be used during ssr
return url.format({
hostname: host,
port,
protocol,
hostname: app.get('host'),
port: app.get('port'),
pathname: path,
protocol: 'http',
})
}