mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-29 07:41:13 +00:00
25 lines
495 B
TypeScript
25 lines
495 B
TypeScript
import { IncomingHttpHeaders } from "http";
|
|
|
|
export function setForwardedHeaders(headers: IncomingHttpHeaders): {
|
|
[key: string]: string;
|
|
} {
|
|
const out: { [key: string]: string } = {};
|
|
|
|
if (headers.host) {
|
|
out.host = headers.host;
|
|
}
|
|
|
|
const realIp = headers["x-real-ip"];
|
|
|
|
if (realIp) {
|
|
out["x-real-ip"] = realIp as string;
|
|
}
|
|
|
|
const forwardedFor = headers["x-forwarded-for"];
|
|
|
|
if (forwardedFor) {
|
|
out["x-forwarded-for"] = forwardedFor as string;
|
|
}
|
|
|
|
return out;
|
|
}
|