Add force SSL config flag

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

View File

@ -1,6 +1,6 @@
{
"name": "@extollo/lib",
"version": "0.9.45",
"version": "0.9.46",
"description": "The framework library that lifts up your code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

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)
}