mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-04 07:46:16 +02:00
fix(Maps): add x-forwarded-proto support to handle https termination (#600)
This commit is contained in:
parent
7711b5f0e8
commit
b65b6d6b35
|
|
@ -95,7 +95,13 @@ export default class MapsController {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = await this.mapService.generateStylesJSON(request.host(), request.protocol())
|
const forwardedProto = request.headers()['x-forwarded-proto'];
|
||||||
|
|
||||||
|
const protocol: string = forwardedProto
|
||||||
|
? (typeof forwardedProto === 'string' ? forwardedProto : request.protocol())
|
||||||
|
: request.protocol();
|
||||||
|
|
||||||
|
const styles = await this.mapService.generateStylesJSON(request.host(), protocol)
|
||||||
return response.json(styles)
|
return response.json(styles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -526,8 +526,20 @@ export class MapService implements IMapService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const host = specifiedHost || getHost()
|
function specifiedHostOrDefault() {
|
||||||
const withProtocol = host.startsWith('http') ? host : `${protocol}://${host}`
|
if(specifiedHost === null) {
|
||||||
|
return getHost()
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const specifiedUrl = new URL(specifiedHost)
|
||||||
|
return specifiedUrl.host
|
||||||
|
} catch (error) {
|
||||||
|
return getHost()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const host = specifiedHostOrDefault();
|
||||||
|
const withProtocol = `${protocol}://${host}`
|
||||||
const baseUrlPath =
|
const baseUrlPath =
|
||||||
process.env.NODE_ENV === 'production' ? childPath : urlJoin(this.mapStoragePath, childPath)
|
process.env.NODE_ENV === 'production' ? childPath : urlJoin(this.mapStoragePath, childPath)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user