mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
Refactor existing code to add the configured domain to connect-src
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
98b0bf25d2
commit
d7986b1920
4 changed files with 29 additions and 20 deletions
|
@ -8,6 +8,7 @@ const deepFreeze = require('deep-freeze')
|
|||
const { Environment, Permission } = require('./enum')
|
||||
const logger = require('../logger')
|
||||
const { getGitCommit, getGitHubURL } = require('./utils')
|
||||
const { buildDomainOriginWithProtocol } = require('./buildDomainOriginWithProtocol')
|
||||
|
||||
const appRootPath = path.resolve(__dirname, '../../')
|
||||
const env = process.env.NODE_ENV || Environment.development
|
||||
|
@ -79,14 +80,6 @@ if (!(config.defaultPermission in config.permission)) {
|
|||
config.defaultPermission = config.permission.editable
|
||||
}
|
||||
|
||||
// cache result, cannot change config in runtime!!!
|
||||
config.isStandardHTTPsPort = (function isStandardHTTPsPort () {
|
||||
return config.useSSL && config.port === 443
|
||||
})()
|
||||
config.isStandardHTTPPort = (function isStandardHTTPPort () {
|
||||
return !config.useSSL && config.port === 80
|
||||
})()
|
||||
|
||||
// Use HTTPS protocol if the internal TLS server is enabled
|
||||
if (config.useSSL === true) {
|
||||
if (config.protocolUseSSL === false) {
|
||||
|
@ -96,17 +89,8 @@ if (config.useSSL === true) {
|
|||
}
|
||||
|
||||
// cache serverURL
|
||||
config.serverURL = (function getserverurl () {
|
||||
let url = ''
|
||||
if (config.domain) {
|
||||
const protocol = config.protocolUseSSL ? 'https://' : 'http://'
|
||||
url = protocol + config.domain
|
||||
if (config.urlAddPort) {
|
||||
if (!config.isStandardHTTPPort || !config.isStandardHTTPsPort) {
|
||||
url += ':' + config.port
|
||||
}
|
||||
}
|
||||
}
|
||||
config.serverURL = (function () {
|
||||
let url = buildDomainOriginWithProtocol(config, 'http')
|
||||
if (config.urlPath) {
|
||||
url += '/' + config.urlPath
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue