API › @builder.io/qwik-city/middleware/node
createQwikCity
export declare function createQwikCity(opts: QwikCityNodeRequestOptions): {
router: (
req: IncomingMessage | Http2ServerRequest,
res: ServerResponse,
next: NodeRequestNextFunction,
) => Promise<void>;
notFound: (
req: IncomingMessage | Http2ServerRequest,
res: ServerResponse,
next: (e: any) => void,
) => Promise<void>;
staticFile: (
req: IncomingMessage | Http2ServerRequest,
res: ServerResponse,
next: (e?: any) => void,
) => Promise<void>;
};
参数
类型
描述
opts
{ router: (req: IncomingMessage | Http2ServerRequest, res: ServerResponse, next: NodeRequestNextFunction) => Promise<void>; notFound: (req: IncomingMessage | Http2ServerRequest, res: ServerResponse, next: (e: any) => void) => Promise<void>; staticFile: (req: IncomingMessage | Http2ServerRequest, res: ServerResponse, next: (e?: any) => void) => Promise<void>; }
NodeRequestNextFunction
export interface NodeRequestNextFunction
PlatformNode
export interface PlatformNode
属性
修饰符
类型
描述
IncomingMessage | Http2ServerRequest
(可选)
string
(可选)
true
(可选)
QwikCityNodeRequestOptions
export interface QwikCityNodeRequestOptions extends ServerRenderOptions
扩展: ServerRenderOptions
属性
修饰符
类型
描述
(req: IncomingMessage | Http2ServerRequest) => ClientConn
(可选) 提供一个函数,该函数返回给定请求的 ClientConn
。
(req: IncomingMessage | Http2ServerRequest) => string | null
(可选) 提供一个函数,该函数计算服务器的来源,用于解析相对 URL 并根据 CSRF 攻击验证请求来源。
如果未指定,则默认为 ORIGIN
环境变量(如果已设置)。
如果未设置 ORIGIN
,则它将从传入的请求中推断出来,这对于生产环境来说是不推荐的。您可以分别将 PROTOCOL_HEADER
、HOST_HEADER
指定为 X-Forwarded-Proto
和 X-Forwarded-Host
来覆盖默认行为。
string
(可选)
{ root?: string; cacheControl?: string; }
(可选) 用于提供静态文件的选项