Add force SSL config flag

This commit is contained in:
2022-06-07 22:45:16 -05:00
parent 48ce1bfa2f
commit afbf6e7682
2 changed files with 6 additions and 1 deletions

View File

@@ -168,10 +168,15 @@ export class Routing extends Unit {
}
public getAppUrl(): UniversalPath {
const forceSsl = Boolean(this.config.get('server.forceSsl', false))
if ( this.request.has() ) {
// If we have a request context, use that URL, as it is the most reliable
const request = this.request.get()
const url = new URL(request.fullUrl)
if ( forceSsl ) {
url.protocol = 'https:'
}
return universalPath(url.origin)
}