mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Fix relative paths and add error handling
This commit is contained in:
parent
356b82f443
commit
617e929e1a
|
@ -1,7 +1,7 @@
|
||||||
import Constants = require("../../../../../shared/constants");
|
import Constants = require("../../../../shared/constants");
|
||||||
import Express = require("express");
|
import Express = require("express");
|
||||||
import GetHeader from "../../utils/GetHeader";
|
import GetHeader from "./GetHeader";
|
||||||
import HasHeader from "../..//utils/HasHeader";
|
import HasHeader from "./HasHeader";
|
||||||
|
|
||||||
export class RequestUrlGetter {
|
export class RequestUrlGetter {
|
||||||
static getOriginalUrl(req: Express.Request): string {
|
static getOriginalUrl(req: Express.Request): string {
|
||||||
|
@ -15,6 +15,11 @@ export class RequestUrlGetter {
|
||||||
const port = GetHeader(req, Constants.HEADER_X_FORWARDED_PORT);
|
const port = GetHeader(req, Constants.HEADER_X_FORWARDED_PORT);
|
||||||
const uri = GetHeader(req, Constants.HEADER_X_FORWARDED_URI);
|
const uri = GetHeader(req, Constants.HEADER_X_FORWARDED_URI);
|
||||||
|
|
||||||
|
if (!proto || !host || !port) {
|
||||||
|
throw new Error("Missing headers holding requested URL. Requires X-Original-Url or X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port")
|
||||||
|
}
|
||||||
|
|
||||||
return "${proto}://${host}:${port}${uri}";
|
return "${proto}://${host}:${port}${uri}";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user