diff --git a/package.json b/package.json index d3aa6c5..17be179 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.44", + "version": "0.9.45", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/service/Routing.ts b/src/service/Routing.ts index e5165ea..c6294e4 100644 --- a/src/service/Routing.ts +++ b/src/service/Routing.ts @@ -169,11 +169,20 @@ export class Routing extends Unit { public getAppUrl(): UniversalPath { if ( this.request.has() ) { + // If we have a request context, use that URL, as it is the most reliable const request = this.request.get() - this.logging.debug(`url: ${request.url} | fullUrl: ${request.fullUrl}`) + const url = new URL(request.fullUrl) + return universalPath(url.origin) } - const rawHost = String(this.config.get('server.url', 'http://localhost')).toLowerCase() + const urlOverride = String(this.config.get('server.url', '')).toLowerCase() + if ( urlOverride ) { + // If the config has a URL override explicitly set, use that + return universalPath(urlOverride) + } + + // Otherwise, try to build one from the host and port + const rawHost = String(this.config.get('server.host', 'http://localhost')).toLowerCase() const isSSL = rawHost.startsWith('https://') const port = this.config.get('server.port', 8000)