MCPcopy
hub / github.com/vitejs/vite / resolveHttpServer

Function resolveHttpServer

packages/vite/src/node/http.ts:119–144  ·  view source on GitHub ↗
(
  app: Connect.Server,
  httpsOptions?: HttpsServerOptions,
)

Source from the content-addressed store, hash-verified

117export type CorsOrigin = boolean | string | RegExp | (string | RegExp)[]
118
119export async function resolveHttpServer(
120 app: Connect.Server,
121 httpsOptions?: HttpsServerOptions,
122): Promise<HttpServer> {
123 if (!httpsOptions) {
124 const { createServer } = await import('node:http')
125 return createServer(app)
126 }
127
128 const { createSecureServer } = await import('node:http2')
129 return createSecureServer(
130 {
131 // Manually increase the session memory to prevent 502 ENHANCE_YOUR_CALM
132 // errors on large numbers of requests
133 maxSessionMemory: 1000,
134 // Increase the stream reset rate limit to prevent net::ERR_HTTP2_PROTOCOL_ERROR
135 // errors on large numbers of requests
136 streamResetBurst: 100000,
137 streamResetRate: 33,
138 ...httpsOptions,
139 allowHTTP1: true,
140 },
141 // @ts-expect-error TODO: is this correct?
142 app,
143 )
144}
145
146export async function resolveHttpsConfig(
147 https: HttpsServerOptions | undefined,

Callers 2

previewFunction · 0.90
_createServerFunction · 0.90

Calls 1

createServerFunction · 0.50

Tested by

no test coverage detected