nitro 3.0.260429-beta → 3.0.260522-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_build/common.mjs +119 -21
- package/dist/_build/rolldown.mjs +6 -6
- package/dist/_build/rollup.mjs +11 -11
- package/dist/_build/vite.build.mjs +3 -3
- package/dist/_build/vite.dev.mjs +149 -0
- package/dist/_build/vite.env.mjs +177 -0
- package/dist/_chunks/nitro.mjs +239 -12
- package/dist/_chunks/nitro2.mjs +117 -90
- package/dist/_chunks/utils.mjs +4 -4
- package/dist/_common.mjs +1 -1
- package/dist/_dev.d.mts +1 -1
- package/dist/_dev.mjs +5 -5
- package/dist/_libs/c12+rc9.mjs +11 -10
- package/dist/_libs/c12+readdirp+chokidar.d.mts +7 -8
- package/dist/_libs/citty.mjs +1 -1
- package/dist/_libs/common.d.mts +37 -0
- package/dist/_libs/commondir+is-reference.mjs +3 -3
- package/dist/_libs/compatx.d.mts +1 -1
- package/dist/_libs/compatx.mjs +1 -1
- package/dist/_libs/estree+pluginutils.d.mts +1 -1
- package/dist/_libs/estree-walker.mjs +1 -1
- package/dist/_libs/hasown+resolve+deepmerge.mjs +15 -15
- package/dist/_libs/httpxy.d.mts +1 -1
- package/dist/_libs/httpxy.mjs +8 -4
- package/dist/_libs/jsonc-parser+workers-utils.d.mts +1579 -0
- package/dist/_libs/klona.mjs +1 -1
- package/dist/_libs/magic-string.d.mts +1 -1
- package/dist/_libs/mlly.d.mts +1 -1
- package/dist/_libs/nypm+tinyexec.mjs +92 -99
- package/dist/_libs/openapi-types.d.mts +730 -0
- package/dist/_libs/perfect-debounce.mjs +1 -1
- package/dist/_libs/pkg-types.d.mts +1 -1
- package/dist/_libs/plugin-alias.mjs +2 -2
- package/dist/_libs/plugin-inject.mjs +3 -3
- package/dist/_libs/plugin-json.mjs +2 -2
- package/dist/_libs/pluginutils.mjs +16 -5
- package/dist/_libs/readdirp+chokidar.mjs +2 -2
- package/dist/_libs/remapping.mjs +2 -2
- package/dist/_libs/resolve-uri+gen-mapping.mjs +2 -5
- package/dist/_libs/rou3.d.mts +1 -1
- package/dist/_libs/rou3.mjs +1 -1
- package/dist/_libs/std-env.d.mts +1 -1
- package/dist/_libs/tsconfck.mjs +1 -1
- package/dist/_libs/ultrahtml.mjs +1 -1
- package/dist/_libs/{unimport+unplugin+oxc-parser.mjs → unimport+unplugin.mjs} +18 -8
- package/dist/_libs/unplugin+unimport.d.mts +3 -3
- package/dist/_libs/unwasm.d.mts +1 -1
- package/dist/_presets.mjs +117 -91
- package/dist/builder.d.mts +1 -1
- package/dist/builder.mjs +3 -3
- package/dist/cli/_chunks/build.mjs +3 -3
- package/dist/cli/_chunks/common.mjs +1 -1
- package/dist/cli/_chunks/deploy.mjs +2 -2
- package/dist/cli/_chunks/dev.mjs +4 -4
- package/dist/cli/_chunks/docs.mjs +1 -1
- package/dist/cli/_chunks/list.mjs +2 -2
- package/dist/cli/_chunks/prepare.mjs +3 -3
- package/dist/cli/_chunks/preview.mjs +4 -4
- package/dist/cli/_chunks/run.mjs +2 -2
- package/dist/cli/_chunks/task.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +3 -3
- package/dist/docs/1.deploy/2.providers/21.vercel.md +6 -0
- package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +1 -1
- package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
- package/dist/runtime/internal/app.mjs +4 -111
- package/dist/runtime/virtual/app.d.mts +4 -0
- package/dist/runtime/virtual/app.mjs +32 -0
- package/dist/types/index.d.mts +21 -1756
- package/dist/vite.mjs +23 -337
- package/package.json +37 -39
- package/dist/THIRD-PARTY-LICENSES.md +0 -1676
- package/dist/_chunks/nitro3.mjs +0 -136
- package/dist/_chunks/nitro4.mjs +0 -127
package/dist/_chunks/utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __commonJSMin, __require } from "../_common.mjs";
|
|
2
|
+
import { dirname, glob, m, relative, resolve, resolveModulePath, runParallel, v } from "../_build/common.mjs";
|
|
3
3
|
import { consola as consola$1 } from "consola";
|
|
4
4
|
import { promises } from "node:fs";
|
|
5
5
|
import { promisify } from "node:util";
|
|
@@ -257,9 +257,9 @@ async function importDep(opts, _retry) {
|
|
|
257
257
|
if (!shouldInstall) throw new Error(`\`${opts.id}\` is not installed. Please add it to your dependencies for ${opts.reason}.`);
|
|
258
258
|
const start = Date.now();
|
|
259
259
|
consola$1.start(`Installing \`${opts.id}\` in \`${opts.dir}\`...`);
|
|
260
|
-
const { addDevDependency } = await import("../_libs/nypm+tinyexec.mjs").then((n) => n.
|
|
260
|
+
const { addDevDependency } = await import("../_libs/nypm+tinyexec.mjs").then((n) => n.dist_exports);
|
|
261
261
|
await addDevDependency(opts.id, { cwd: opts.dir });
|
|
262
262
|
consola$1.success(`Installed \`${opts.id}\` in ${opts.dir} (${Date.now() - start}ms).`);
|
|
263
263
|
return importDep(opts, true);
|
|
264
264
|
}
|
|
265
|
-
export { generateFSTree
|
|
265
|
+
export { generateFSTree, importDep };
|
package/dist/_common.mjs
CHANGED
|
@@ -30,4 +30,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
enumerable: true
|
|
31
31
|
}) : target, mod));
|
|
32
32
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
33
|
-
export {
|
|
33
|
+
export { __commonJSMin, __exportAll, __require, __toESM };
|
package/dist/_dev.d.mts
CHANGED
package/dist/_dev.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { extname as extname$1, join as join$1, m, resolve as resolve$1, src_default, v, writeDevBuildInfo } from "./_build/common.mjs";
|
|
2
|
+
import { watch as watch$1 } from "./_libs/readdirp+chokidar.mjs";
|
|
3
|
+
import { debounce } from "./_libs/perfect-debounce.mjs";
|
|
4
|
+
import { createProxyServer } from "./_libs/httpxy.mjs";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import { createReadStream } from "node:fs";
|
|
7
7
|
import { readFile, stat as stat$1 } from "node:fs/promises";
|
|
@@ -507,4 +507,4 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
507
507
|
});
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
|
-
export {
|
|
510
|
+
export { NitroDevApp, NitroDevServer, createDevServer };
|
package/dist/_libs/c12+rc9.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __exportAll as __exportAll$1 } from "../_common.mjs";
|
|
2
|
+
import { basename as basename$1, dirname as dirname$1, extname as extname$1, findWorkspaceDir, join as join$1, normalize as normalize$1, readPackageJSON, resolve as resolve$1, resolveModulePath } from "../_build/common.mjs";
|
|
3
3
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
import * as nodeUtil from "node:util";
|
|
5
5
|
import { readFile, rm } from "node:fs/promises";
|
|
@@ -304,11 +304,11 @@ function getDotEnvVars(targetEnvironment) {
|
|
|
304
304
|
const _normalize = (p) => p?.replace(/\\/g, "/");
|
|
305
305
|
let importCounter = 0;
|
|
306
306
|
const ASYNC_LOADERS = {
|
|
307
|
-
".yaml": () => import("../_build/common.mjs").then((n) => n
|
|
308
|
-
".yml": () => import("../_build/common.mjs").then((n) => n
|
|
309
|
-
".jsonc": () => import("../_build/common.mjs").then((n) => n.
|
|
310
|
-
".json5": () => import("../_build/common.mjs").then((n) => n.
|
|
311
|
-
".toml": () => import("../_build/common.mjs").then((n) => n.
|
|
307
|
+
".yaml": () => import("../_build/common.mjs").then((n) => n.yaml_exports).then((r) => r.parseYAML),
|
|
308
|
+
".yml": () => import("../_build/common.mjs").then((n) => n.yaml_exports).then((r) => r.parseYAML),
|
|
309
|
+
".jsonc": () => import("../_build/common.mjs").then((n) => n.jsonc_exports).then((r) => r.parseJSONC),
|
|
310
|
+
".json5": () => import("../_build/common.mjs").then((n) => n.json5_exports).then((r) => r.parseJSON5),
|
|
311
|
+
".toml": () => import("../_build/common.mjs").then((n) => n.toml_exports).then((r) => r.parseTOML)
|
|
312
312
|
};
|
|
313
313
|
const SUPPORTED_EXTENSIONS = Object.freeze([
|
|
314
314
|
".js",
|
|
@@ -539,7 +539,8 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
539
539
|
const jiti = createJiti(join$1(options.cwd || ".", options.configFile || "/"), {
|
|
540
540
|
interopDefault: true,
|
|
541
541
|
moduleCache: false,
|
|
542
|
-
extensions: [...SUPPORTED_EXTENSIONS]
|
|
542
|
+
extensions: [...SUPPORTED_EXTENSIONS],
|
|
543
|
+
...options.jitiOptions
|
|
543
544
|
});
|
|
544
545
|
options.import = (id) => jiti.import(id);
|
|
545
546
|
return _resolveModule(await options.import(res.configFile));
|
|
@@ -597,7 +598,7 @@ async function watchConfig(options) {
|
|
|
597
598
|
options.rcFile && resolve$1(l.cwd, typeof options.rcFile === "string" ? options.rcFile : `.${configName}rc`),
|
|
598
599
|
options.packageJson && resolve$1(l.cwd, "package.json")
|
|
599
600
|
]).filter(Boolean))];
|
|
600
|
-
const watch = await import("./readdirp+chokidar.mjs").then((n) => n.
|
|
601
|
+
const watch = await import("./readdirp+chokidar.mjs").then((n) => n.chokidar_exports).then((r) => r.watch || r.default || r);
|
|
601
602
|
const { diff } = await Promise.resolve().then(() => ohash_exports).then((n) => n.t);
|
|
602
603
|
const _fswatcher = watch(watchingFiles, {
|
|
603
604
|
ignoreInitial: true,
|
|
@@ -823,4 +824,4 @@ var DiffHashedObject = class {
|
|
|
823
824
|
return `${k}(${this.value})`;
|
|
824
825
|
}
|
|
825
826
|
};
|
|
826
|
-
export {
|
|
827
|
+
export { dist_exports$1 as dist_exports, loadConfig, watchConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Stats } from "node:fs";
|
|
2
2
|
import { EventEmitter } from "node:events";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
|
+
import * as _$jiti from "jiti";
|
|
4
5
|
import { DownloadTemplateOptions } from "giget";
|
|
5
|
-
//#region node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/utils/index.d.mts
|
|
6
6
|
/**
|
|
7
7
|
* Calculates the difference between two objects and returns a list of differences.
|
|
8
8
|
*
|
|
@@ -29,7 +29,7 @@ declare class DiffHashedObject {
|
|
|
29
29
|
constructor(key: string, value: any, hash?: string | undefined, props?: Record<string, DiffHashedObject> | undefined);
|
|
30
30
|
toString(): string;
|
|
31
31
|
toJSON(): string;
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
type AWF = {
|
|
34
34
|
stabilityThreshold: number;
|
|
35
35
|
pollInterval: number;
|
|
@@ -57,7 +57,6 @@ interface MatcherObject {
|
|
|
57
57
|
recursive?: boolean;
|
|
58
58
|
}
|
|
59
59
|
type Matcher = string | RegExp | MatchFunction | MatcherObject;
|
|
60
|
-
//#region src/dotenv.d.ts
|
|
61
60
|
interface DotenvOptions {
|
|
62
61
|
/**
|
|
63
62
|
* The project root directory (either absolute or relative to the current working directory).
|
|
@@ -105,8 +104,8 @@ interface DotenvOptions {
|
|
|
105
104
|
}
|
|
106
105
|
declare global {
|
|
107
106
|
var __c12_dotenv_vars__: Map<Record<string, any>, Set<string>>;
|
|
108
|
-
}
|
|
109
|
-
|
|
107
|
+
}
|
|
108
|
+
type JitiOptions = NonNullable<Parameters<typeof _$jiti.createJiti>[1]>;
|
|
110
109
|
interface ConfigLayerMeta {
|
|
111
110
|
name?: string;
|
|
112
111
|
[key: string]: any;
|
|
@@ -188,6 +187,8 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
|
|
|
188
187
|
import?: (id: string) => Promise<unknown>;
|
|
189
188
|
/** Custom resolver for picking which export to use from the loaded module. Default: `(mod) => mod.default || mod` */
|
|
190
189
|
resolveModule?: (mod: any) => any;
|
|
190
|
+
/** Options to override defaults when c12 falls back to [jiti](https://github.com/unjs/jiti) for loading config files. */
|
|
191
|
+
jitiOptions?: JitiOptions;
|
|
191
192
|
giget?: false | DownloadTemplateOptions;
|
|
192
193
|
merger?: (...sources: Array<T | null | undefined>) => T;
|
|
193
194
|
extend?: false | {
|
|
@@ -195,8 +196,6 @@ interface LoadConfigOptions<T extends UserInputConfig = UserInputConfig, MT exte
|
|
|
195
196
|
};
|
|
196
197
|
configFileRequired?: boolean;
|
|
197
198
|
}
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region src/watch.d.ts
|
|
200
199
|
type DiffEntries = ReturnType<typeof diff>;
|
|
201
200
|
type ConfigWatcher<T extends UserInputConfig = UserInputConfig, MT extends ConfigLayerMeta = ConfigLayerMeta> = ResolvedConfig<T, MT> & {
|
|
202
201
|
watchingFiles: string[];
|
|
@@ -220,4 +219,4 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
|
|
|
220
219
|
oldConfig: ResolvedConfig<T, MT>;
|
|
221
220
|
}) => void | Promise<void>;
|
|
222
221
|
}
|
|
223
|
-
export {
|
|
222
|
+
export { C12InputConfig, ChokidarOptions, type ConfigWatcher, type DotenvOptions, ResolvedConfig, type WatchConfigOptions };
|
package/dist/_libs/citty.mjs
CHANGED
|
@@ -461,4 +461,4 @@ function _getBuiltinFlags(long, short, userNames, userAliases) {
|
|
|
461
461
|
if (userNames.has(short) || userAliases.has(short)) return [`--${long}`];
|
|
462
462
|
return [`--${long}`, `-${short}`];
|
|
463
463
|
}
|
|
464
|
-
export {
|
|
464
|
+
export { defineCommand, runMain };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface OutputBundleConfig {
|
|
2
|
+
version: "v1";
|
|
3
|
+
runConfig: RunConfig;
|
|
4
|
+
metadata: Metadata;
|
|
5
|
+
outputFiles?: OutputFiles;
|
|
6
|
+
}
|
|
7
|
+
interface RunConfig {
|
|
8
|
+
runCommand: string;
|
|
9
|
+
environmentVariables?: EnvVarConfig[];
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
cpu?: number;
|
|
12
|
+
memoryMiB?: number;
|
|
13
|
+
minInstances?: number;
|
|
14
|
+
maxInstances?: number;
|
|
15
|
+
}
|
|
16
|
+
interface Metadata {
|
|
17
|
+
adapterPackageName: string;
|
|
18
|
+
adapterVersion: string;
|
|
19
|
+
framework: string;
|
|
20
|
+
frameworkVersion?: string;
|
|
21
|
+
}
|
|
22
|
+
interface OutputFiles {
|
|
23
|
+
serverApp: ServerApp;
|
|
24
|
+
}
|
|
25
|
+
interface ServerApp {
|
|
26
|
+
include: string[];
|
|
27
|
+
}
|
|
28
|
+
interface EnvVarConfig {
|
|
29
|
+
variable: string;
|
|
30
|
+
value: string;
|
|
31
|
+
availability: Availability[];
|
|
32
|
+
}
|
|
33
|
+
declare enum Availability {
|
|
34
|
+
Runtime = "RUNTIME",
|
|
35
|
+
Build = "BUILD"
|
|
36
|
+
}
|
|
37
|
+
export { OutputBundleConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __commonJSMin, __require, __toESM } from "../_common.mjs";
|
|
2
|
+
import { Builder, MagicString, attachScopes, createFilter, extractAssignedNames, makeLegalIdentifier, walk } from "../_build/common.mjs";
|
|
3
3
|
import { existsSync, readFileSync, statSync } from "fs";
|
|
4
4
|
import { basename, dirname, extname, join, relative, resolve, sep } from "path";
|
|
5
5
|
var import_commondir = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -1301,4 +1301,4 @@ function commonjs(options = {}) {
|
|
|
1301
1301
|
}
|
|
1302
1302
|
};
|
|
1303
1303
|
}
|
|
1304
|
-
export { commonjs
|
|
1304
|
+
export { commonjs };
|
package/dist/_libs/compatx.d.mts
CHANGED
|
@@ -42,4 +42,4 @@ type CompatibilityDateSpec = DateString | Partial<CompatibilityDates>;
|
|
|
42
42
|
/**
|
|
43
43
|
* Get compatibility updates applicable for the user given platform and date range.
|
|
44
44
|
*/
|
|
45
|
-
export { CompatibilityDates
|
|
45
|
+
export type { CompatibilityDateSpec, CompatibilityDates, DateString };
|
package/dist/_libs/compatx.mjs
CHANGED
|
@@ -40,4 +40,4 @@ function normalizeDate(date) {
|
|
|
40
40
|
if (date === "latest") return /* @__PURE__ */ new Date();
|
|
41
41
|
return new Date(date);
|
|
42
42
|
}
|
|
43
|
-
export { resolveCompatibilityDates
|
|
43
|
+
export { formatCompatibilityDate, resolveCompatibilityDates, resolveCompatibilityDatesFromEnv };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __commonJSMin, __require, __toESM } from "../_common.mjs";
|
|
2
|
+
import { createFilter } from "../_build/common.mjs";
|
|
3
3
|
import { builtinModules } from "module";
|
|
4
4
|
import fs, { realpathSync } from "fs";
|
|
5
5
|
import path, { dirname, extname, normalize, resolve, sep } from "path";
|
|
@@ -346,18 +346,18 @@ var require_core$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
346
346
|
"node:sea": [">= 20.12 && < 21", ">= 21.7"],
|
|
347
347
|
"smalloc": ">= 0.11.5 && < 3",
|
|
348
348
|
"node:sqlite": [">= 22.13 && < 23", ">= 23.4"],
|
|
349
|
-
"_stream_duplex": ">= 0.9.4",
|
|
350
|
-
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
|
|
351
|
-
"_stream_transform": ">= 0.9.4",
|
|
352
|
-
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
|
|
353
|
-
"_stream_wrap": ">= 1.4.1",
|
|
354
|
-
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
|
|
355
|
-
"_stream_passthrough": ">= 0.9.4",
|
|
356
|
-
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
|
|
357
|
-
"_stream_readable": ">= 0.9.4",
|
|
358
|
-
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
|
|
359
|
-
"_stream_writable": ">= 0.9.4",
|
|
360
|
-
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
|
|
349
|
+
"_stream_duplex": ">= 0.9.4 && < 26",
|
|
350
|
+
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16 && < 26"],
|
|
351
|
+
"_stream_transform": ">= 0.9.4 && < 26",
|
|
352
|
+
"node:_stream_transform": [">= 14.18 && < 15", ">= 16 && < 26"],
|
|
353
|
+
"_stream_wrap": ">= 1.4.1 && < 26",
|
|
354
|
+
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16 && < 26"],
|
|
355
|
+
"_stream_passthrough": ">= 0.9.4 && < 26",
|
|
356
|
+
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16 && < 26"],
|
|
357
|
+
"_stream_readable": ">= 0.9.4 && < 26",
|
|
358
|
+
"node:_stream_readable": [">= 14.18 && < 15", ">= 16 && < 26"],
|
|
359
|
+
"_stream_writable": ">= 0.9.4 && < 26",
|
|
360
|
+
"node:_stream_writable": [">= 14.18 && < 15", ">= 16 && < 26"],
|
|
361
361
|
"stream": true,
|
|
362
362
|
"node:stream": [">= 14.18 && < 15", ">= 16"],
|
|
363
363
|
"stream/consumers": ">= 16.7",
|
|
@@ -1896,4 +1896,4 @@ function nodeResolve(opts = {}) {
|
|
|
1896
1896
|
}
|
|
1897
1897
|
};
|
|
1898
1898
|
}
|
|
1899
|
-
export { nodeResolve
|
|
1899
|
+
export { nodeResolve };
|
package/dist/_libs/httpxy.d.mts
CHANGED
package/dist/_libs/httpxy.mjs
CHANGED
|
@@ -40,6 +40,10 @@ function setupOutgoing(outgoing, options, req, forward) {
|
|
|
40
40
|
const value = options[forward || "target"][e];
|
|
41
41
|
if (value !== void 0) outgoing[e] = value;
|
|
42
42
|
}
|
|
43
|
+
if (outgoing.host === void 0 && typeof outgoing.hostname === "string") {
|
|
44
|
+
const bracketedHost = outgoing.hostname.includes(":") && !outgoing.hostname.startsWith("[") ? `[${outgoing.hostname}]` : outgoing.hostname;
|
|
45
|
+
outgoing.host = outgoing.port ? `${bracketedHost}:${outgoing.port}` : bracketedHost;
|
|
46
|
+
}
|
|
43
47
|
outgoing.method = options.method || req.method;
|
|
44
48
|
outgoing.headers = { ...req.headers };
|
|
45
49
|
if (req.headers?.[":authority"]) outgoing.headers.host = req.headers[":authority"];
|
|
@@ -550,15 +554,15 @@ function _createProxyFn(type, server) {
|
|
|
550
554
|
for (const pass of server._getPasses(type)) {
|
|
551
555
|
let stop;
|
|
552
556
|
try {
|
|
553
|
-
stop = pass(req, res, requestOptions, server, head, (error) => {
|
|
557
|
+
stop = pass(req, res, requestOptions, server, head, (error, _req, _res, url) => {
|
|
554
558
|
if (server.listenerCount("error") > 0) {
|
|
555
|
-
server.emit("error", error, req, res);
|
|
559
|
+
server.emit("error", error, req, res, url);
|
|
556
560
|
_resolve();
|
|
557
561
|
} else _reject(error);
|
|
558
562
|
});
|
|
559
563
|
} catch (error) {
|
|
560
564
|
if (server.listenerCount("error") > 0) {
|
|
561
|
-
server.emit("error", error, req, res);
|
|
565
|
+
server.emit("error", error, req, res, requestOptions.target || requestOptions.forward);
|
|
562
566
|
_resolve();
|
|
563
567
|
} else _reject(error);
|
|
564
568
|
break;
|
|
@@ -836,4 +840,4 @@ function _createHttpHeader(line, headers) {
|
|
|
836
840
|
}
|
|
837
841
|
return `${result}\r\n\r\n`;
|
|
838
842
|
}
|
|
839
|
-
export { proxyFetch
|
|
843
|
+
export { createProxyServer, proxyFetch, proxyUpgrade };
|