Back to Qwik

@builder.io/qwik-city/middleware/node API Reference

packages/docs/src/routes/api/qwik-city-middleware-node/index.mdx

1.7.13.7 KB
Original Source

API › @builder.io/qwik-city/middleware/node

<h2 id="createqwikcity">createQwikCity</h2>
typescript
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>;
};
<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

opts

</td><td>

QwikCityNodeRequestOptions

</td><td> </td></tr> </tbody></table>

Returns:

{ 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>; }

Edit this section

<h2 id="noderequestnextfunction">NodeRequestNextFunction</h2>
typescript
export interface NodeRequestNextFunction

Edit this section

<h2 id="platformnode">PlatformNode</h2>
typescript
export interface PlatformNode
<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

incomingMessage?

</td><td> </td><td>

IncomingMessage | Http2ServerRequest

</td><td>

(Optional)

</td></tr> <tr><td>

node?

</td><td> </td><td>

string

</td><td>

(Optional)

</td></tr> <tr><td>

ssr?

</td><td> </td><td>

true

</td><td>

(Optional)

</td></tr> </tbody></table>

Edit this section

<h2 id="qwikcitynoderequestoptions">QwikCityNodeRequestOptions</h2>
typescript
export interface QwikCityNodeRequestOptions extends ServerRenderOptions

Extends: ServerRenderOptions

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

getClientConn?

</td><td> </td><td>

(req: IncomingMessage | Http2ServerRequest) => ClientConn

</td><td>

(Optional) Provide a function that returns a ClientConn for the given request.

</td></tr> <tr><td>

getOrigin?

</td><td> </td><td>

(req: IncomingMessage | Http2ServerRequest) => string | null

</td><td>

(Optional) Provide a function that computes the origin of the server, used to resolve relative URLs and validate the request origin against CSRF attacks.

When not specified, it defaults to the ORIGIN environment variable (if set).

If ORIGIN is not set, it's derived from the incoming request, which is not recommended for production use. You can specify the PROTOCOL_HEADER, HOST_HEADER to X-Forwarded-Proto and X-Forwarded-Host respectively to override the default behavior.

</td></tr> <tr><td>

origin?

</td><td> </td><td>

string

</td><td>

(Optional)

</td></tr> <tr><td>

static?

</td><td> </td><td>

{ root?: string; cacheControl?: string; }

</td><td>

(Optional) Options for serving static files

</td></tr> </tbody></table>

Edit this section