MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / createHostCheck

Function createHostCheck

packages/server/src/middleware/hostnames.ts:161–172  ·  view source on GitHub ↗
(opts: HostCheckOptions)

Source from the content-addressed store, hash-verified

159 * route handler never runs.
160 */
161export function createHostCheck(opts: HostCheckOptions): HostCheck {
162 const isAllowed = (host: string | undefined): boolean => isAllowedHost(host, opts);
163 const onRequest = async (
164 req: FastifyRequest,
165 reply: FastifyReply,
166 ): Promise<FastifyReply | void> => {
167 if (!isAllowed(req.headers.host)) {
168 return reply.code(403).send(errEnvelope(HOST_ERROR_CODE, formatHostErrorMessage(req.headers.host), req.id));
169 }
170 };
171 return { onRequest, isAllowed };
172}

Callers 2

hostnames.test.tsFile · 0.90
startServerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected