16 lines
351 B
TypeScript
16 lines
351 B
TypeScript
import type { IncomingMessage } from 'node:http'
|
|
|
|
type ProxyRequestLike = {
|
|
setHeader: (name: string, value: string) => void
|
|
}
|
|
|
|
export const forwardOriginalHost = (
|
|
proxyReq: ProxyRequestLike,
|
|
req: IncomingMessage
|
|
) => {
|
|
const host = req.headers.host
|
|
if (typeof host === 'string' && host.trim()) {
|
|
proxyReq.setHeader('host', host)
|
|
}
|
|
}
|