Improve app URL detection
This commit is contained in:
parent
1d717e0eb9
commit
48ce1bfa2f
@ -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",
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user