apiblaze 0.9.0 → 0.10.0
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/index.js +74 -22
- package/dist/sidecar/index.js +7 -6
- package/dist/sidecar/index.mjs +7 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -305,7 +305,7 @@ var import_commander = require("commander");
|
|
|
305
305
|
var import_chalk30 = __toESM(require("chalk"));
|
|
306
306
|
|
|
307
307
|
// package.json
|
|
308
|
-
var version = "0.
|
|
308
|
+
var version = "0.10.0";
|
|
309
309
|
|
|
310
310
|
// src/index.ts
|
|
311
311
|
init_types();
|
|
@@ -3266,11 +3266,31 @@ function upsertEnvLocal(root, token) {
|
|
|
3266
3266
|
`;
|
|
3267
3267
|
if (!/^APIBLAZE_SIDECAR=/m.test(next)) {
|
|
3268
3268
|
next = (next.endsWith("\n") ? next : next + "\n") + `APIBLAZE_SIDECAR=on
|
|
3269
|
+
`;
|
|
3270
|
+
}
|
|
3271
|
+
if (!/^APIBLAZE_SIDECAR_VERBOSE=/m.test(next)) {
|
|
3272
|
+
next = (next.endsWith("\n") ? next : next + "\n") + `APIBLAZE_SIDECAR_VERBOSE=true
|
|
3269
3273
|
`;
|
|
3270
3274
|
}
|
|
3271
3275
|
fs7.writeFileSync(p, next);
|
|
3272
3276
|
return had ? "rotated" : "created";
|
|
3273
3277
|
}
|
|
3278
|
+
function installSidecarPackage(root) {
|
|
3279
|
+
if (fs7.existsSync(path4.join(root, "node_modules", "apiblaze", "package.json"))) {
|
|
3280
|
+
console.log(` ${import_chalk28.default.green("\u2713")} apiblaze package already installed`);
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3283
|
+
const has = (f) => fs7.existsSync(path4.join(root, f));
|
|
3284
|
+
const pm = has("bun.lockb") || has("bun.lock") ? { cmd: "bun", add: "add" } : has("pnpm-lock.yaml") ? { cmd: "pnpm", add: "add" } : has("yarn.lock") ? { cmd: "yarn", add: "add" } : { cmd: "npm", add: "install" };
|
|
3285
|
+
const spinner = (0, import_ora13.default)(`Installing the apiblaze package (${pm.cmd})\u2026`).start();
|
|
3286
|
+
try {
|
|
3287
|
+
const { execSync } = require("child_process");
|
|
3288
|
+
execSync(`${pm.cmd} ${pm.add} apiblaze`, { cwd: root, stdio: "ignore" });
|
|
3289
|
+
spinner.succeed("Installed apiblaze (the sidecar runtime).");
|
|
3290
|
+
} catch {
|
|
3291
|
+
spinner.warn(`Couldn't auto-install \u2014 run ${import_chalk28.default.cyan(`${pm.cmd} ${pm.add} apiblaze`)} yourself before ${import_chalk28.default.cyan("npm run dev")}.`);
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3274
3294
|
function readEnvKey(root) {
|
|
3275
3295
|
try {
|
|
3276
3296
|
const s = fs7.readFileSync(path4.join(root, ".env.local"), "utf8");
|
|
@@ -3328,16 +3348,46 @@ async function probe(u: string) {
|
|
|
3328
3348
|
}
|
|
3329
3349
|
|
|
3330
3350
|
export default async function Page() {
|
|
3331
|
-
if (process.env.NODE_ENV === "production") return <main style={{padding:24}}>Inspector disabled in production.</main>;
|
|
3332
|
-
const r = await probe("https://httpbingo.org/headers");
|
|
3351
|
+
if (process.env.NODE_ENV === "production") return <main style={{ padding: 24 }}>Inspector disabled in production.</main>;
|
|
3352
|
+
const r: any = await probe("https://httpbingo.org/headers");
|
|
3353
|
+
const hdrs = (r && r.echo && r.echo.headers) || {};
|
|
3354
|
+
// The sidecar sets X-Abz-Fwd-X-Api-Key ONLY when it routes a call through a proxy.
|
|
3355
|
+
const routed = Boolean(hdrs["X-Abz-Fwd-X-Api-Key"] || hdrs["x-abz-fwd-x-api-key"]);
|
|
3356
|
+
const card: any = { background: "#0b0f17", border: "1px solid #232a36", borderRadius: 14, padding: 20 };
|
|
3357
|
+
const pill: any = { display: "inline-block", padding: "4px 10px", borderRadius: 999, fontSize: 12, fontWeight: 700 };
|
|
3333
3358
|
return (
|
|
3334
|
-
<main style={{ fontFamily: "ui-monospace, monospace", padding:
|
|
3335
|
-
<
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3359
|
+
<main style={{ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", background: "#070a10", minHeight: "100vh", padding: 32, color: "#e6e9ef", lineHeight: 1.6 }}>
|
|
3360
|
+
<div style={{ maxWidth: 720, margin: "0 auto" }}>
|
|
3361
|
+
<h1 style={{ fontSize: 20, margin: "0 0 6px" }}>APIblaze sidecar \u2014 live inspector</h1>
|
|
3362
|
+
<p style={{ color: "#9aa4b2", margin: "0 0 20px", fontSize: 14 }}>
|
|
3363
|
+
This dev-only page makes one real call to <b style={{ color: "#e6e9ef" }}>httpbingo.org</b> from your server so you can watch the sidecar work. Every external fetch your app makes either <b>routes</b> through APIblaze (once you approve that origin) or goes <b>direct</b>, untouched.
|
|
3364
|
+
</p>
|
|
3365
|
+
<div style={card}>
|
|
3366
|
+
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12, marginBottom: 14, flexWrap: "wrap" }}>
|
|
3367
|
+
<span style={{ fontSize: 15 }}>GET https://httpbingo.org/headers</span>
|
|
3368
|
+
{routed
|
|
3369
|
+
? <span style={{ ...pill, background: "#0f2e20", color: "#4ade80" }}>\u25CF routed through APIblaze</span>
|
|
3370
|
+
: <span style={{ ...pill, background: "#33280c", color: "#fbbf24" }}>\u25CB going direct \u2014 not approved</span>}
|
|
3371
|
+
</div>
|
|
3372
|
+
{routed ? (
|
|
3373
|
+
<p style={{ color: "#9aa4b2", fontSize: 14, margin: 0 }}>
|
|
3374
|
+
This request <b style={{ color: "#4ade80" }}>routed through your APIblaze proxy</b> \u2014 with auth, rate limits, and observability \u2014 and your app code never changed. The proxy swapped in your invoke key and preserved your original one (see <code>X-Abz-Fwd-X-Api-Key</code> in the raw response).
|
|
3375
|
+
</p>
|
|
3376
|
+
) : (
|
|
3377
|
+
<div style={{ color: "#9aa4b2", fontSize: 14 }}>
|
|
3378
|
+
<p style={{ margin: "0 0 10px" }}>This call went <b style={{ color: "#fbbf24" }}>direct</b> \u2014 httpbingo.org isn't approved yet, so the sidecar left it untouched and reported it as a candidate.</p>
|
|
3379
|
+
<p style={{ margin: "0 0 6px", color: "#e6e9ef" }}>Route it through APIblaze:</p>
|
|
3380
|
+
<pre style={{ background: "#070a10", border: "1px solid #232a36", borderRadius: 8, padding: 12, margin: 0, color: "#8ab4ff", overflowX: "auto" }}>npx apiblaze sidecar approve httpbingo.org</pre>
|
|
3381
|
+
<p style={{ margin: "10px 0 0" }}>\u2026wait ~5 min, then <b style={{ color: "#e6e9ef" }}>reload</b>. The badge above turns green.</p>
|
|
3382
|
+
</div>
|
|
3383
|
+
)}
|
|
3384
|
+
</div>
|
|
3385
|
+
<details style={{ marginTop: 16, color: "#9aa4b2", fontSize: 13 }}>
|
|
3386
|
+
<summary style={{ cursor: "pointer" }}>Raw response {r && r.status ? "(HTTP " + r.status + ")" : "(error)"}</summary>
|
|
3387
|
+
<pre style={{ background: "#0b0f17", border: "1px solid #232a36", borderRadius: 10, padding: 14, overflowX: "auto", marginTop: 8 }}>{JSON.stringify(r, null, 2)}</pre>
|
|
3388
|
+
</details>
|
|
3389
|
+
<p style={{ color: "#5b6472", fontSize: 12, marginTop: 20 }}>Dev-only \u2014 delete <code>app/abz-inspector</code> before shipping.</p>
|
|
3390
|
+
</div>
|
|
3341
3391
|
</main>
|
|
3342
3392
|
);
|
|
3343
3393
|
}
|
|
@@ -3378,6 +3428,7 @@ async function runAnonymousInit(root, router, opts) {
|
|
|
3378
3428
|
ensureGitignored(root);
|
|
3379
3429
|
console.log(` ${import_chalk28.default.green("\u2713")} .env.local ${envState} (APIBLAZE_API_KEY) \u2014 gitignored`);
|
|
3380
3430
|
console.log(` ${import_chalk28.default.green("\u2713")} instrumentation.ts ${wireInstrumentation(root)}`);
|
|
3431
|
+
installSidecarPackage(root);
|
|
3381
3432
|
let inspectorPath = null;
|
|
3382
3433
|
if (!opts.noInspector) {
|
|
3383
3434
|
inspectorPath = generateInspector(root, router);
|
|
@@ -3385,9 +3436,9 @@ async function runAnonymousInit(root, router, opts) {
|
|
|
3385
3436
|
}
|
|
3386
3437
|
console.log("");
|
|
3387
3438
|
console.log(import_chalk28.default.bold("Done (no account needed). What happens next:"));
|
|
3388
|
-
console.log(` 1. ${import_chalk28.default.cyan("npm
|
|
3439
|
+
console.log(` 1. ${import_chalk28.default.cyan("npm run dev")} and use your app.`);
|
|
3389
3440
|
console.log(` 2. Each external origin your app calls is logged in the console \u2014 approve one with:`);
|
|
3390
|
-
console.log(` ${import_chalk28.default.cyan("apiblaze
|
|
3441
|
+
console.log(` ${import_chalk28.default.cyan("apiblaze sidecar approve api.stripe.com")} (no login needed)`);
|
|
3391
3442
|
console.log("");
|
|
3392
3443
|
console.log(import_chalk28.default.bold(" \u{1F511} Keep your setup \u2014 claim it into an account:"));
|
|
3393
3444
|
console.log(` ${import_chalk28.default.cyan("apiblaze login")} then ${import_chalk28.default.cyan("apiblaze claim")} ${import_chalk28.default.dim("(no code needed here)")}`);
|
|
@@ -3410,6 +3461,7 @@ async function runSidecar(opts) {
|
|
|
3410
3461
|
ensureGitignored(root);
|
|
3411
3462
|
console.log(` ${import_chalk28.default.green("\u2713")} .env.local present (APIBLAZE_API_KEY) \u2014 reusing`);
|
|
3412
3463
|
console.log(` ${import_chalk28.default.green("\u2713")} instrumentation.ts ${wireInstrumentation(root)}`);
|
|
3464
|
+
installSidecarPackage(root);
|
|
3413
3465
|
console.log(import_chalk28.default.dim(" Log in and run `apiblaze claim <code>` to keep this setup, or `apiblaze login` to manage it."));
|
|
3414
3466
|
return;
|
|
3415
3467
|
}
|
|
@@ -3440,6 +3492,7 @@ async function runSidecar(opts) {
|
|
|
3440
3492
|
console.log(` ${import_chalk28.default.green("\u2713")} .env.local ${envState} (APIBLAZE_API_KEY) \u2014 gitignored`);
|
|
3441
3493
|
const wireState = wireInstrumentation(root);
|
|
3442
3494
|
console.log(` ${import_chalk28.default.green("\u2713")} instrumentation.ts ${wireState}`);
|
|
3495
|
+
installSidecarPackage(root);
|
|
3443
3496
|
let inspectorPath = null;
|
|
3444
3497
|
if (!opts.noInspector) {
|
|
3445
3498
|
inspectorPath = generateInspector(root, detected.router);
|
|
@@ -3447,15 +3500,14 @@ async function runSidecar(opts) {
|
|
|
3447
3500
|
}
|
|
3448
3501
|
console.log("");
|
|
3449
3502
|
console.log(import_chalk28.default.bold("Done. What happens next:"));
|
|
3450
|
-
console.log(` 1. ${import_chalk28.default.cyan("npm
|
|
3451
|
-
console.log(` 2. ${import_chalk28.default.
|
|
3452
|
-
console.log(` 3.
|
|
3453
|
-
console.log(` 4. Approve the ones to route: ${import_chalk28.default.cyan("apiblaze origins approve api.stripe.com")} (or in the dashboard)`);
|
|
3503
|
+
console.log(` 1. ${import_chalk28.default.cyan("npm run dev")} and use your app \u2014 it works exactly as before (all calls go direct).`);
|
|
3504
|
+
console.log(` 2. The origins your app calls appear as ${import_chalk28.default.bold("candidates")} \u2014 list them: ${import_chalk28.default.cyan("apiblaze sidecar")}`);
|
|
3505
|
+
console.log(` 3. Approve the ones to route: ${import_chalk28.default.cyan("apiblaze sidecar approve api.stripe.com")} (or in the dashboard)`);
|
|
3454
3506
|
console.log(` \u2026within ~5 min your app starts routing that origin through APIblaze.`);
|
|
3455
3507
|
if (inspectorPath) console.log(` \u2022 Try it now: open ${import_chalk28.default.underline("http://localhost:3000/abz-inspector")} (dev only; rm ${path4.dirname(inspectorPath)} before shipping)`);
|
|
3456
|
-
if (switchingTeam) console.log(import_chalk28.default.dim(` \u2022 Approved origins are per-team \u2014 re-approve them on ${teamName ?? teamId} with \`apiblaze
|
|
3508
|
+
if (switchingTeam) console.log(import_chalk28.default.dim(` \u2022 Approved origins are per-team \u2014 re-approve them on ${teamName ?? teamId} with \`apiblaze sidecar approve <origin>\`.`));
|
|
3457
3509
|
console.log("");
|
|
3458
|
-
console.log(import_chalk28.default.dim(" Manage: apiblaze
|
|
3510
|
+
console.log(import_chalk28.default.dim(" Manage: apiblaze sidecar (list/approve/deny/remove)"));
|
|
3459
3511
|
console.log(import_chalk28.default.dim(" Rotate: apiblaze init --rotate \xB7 Switch team: apiblaze init --team <name>"));
|
|
3460
3512
|
console.log(import_chalk28.default.dim(" Turn off: set APIBLAZE_SIDECAR=off in .env.local (flip back to on anytime; key stays put)."));
|
|
3461
3513
|
console.log("");
|
|
@@ -3503,8 +3555,8 @@ Candidates \u2014 going direct, not yet approved (${candidates.length})`));
|
|
|
3503
3555
|
}
|
|
3504
3556
|
if (candidates.length) {
|
|
3505
3557
|
console.log(import_chalk29.default.dim(`
|
|
3506
|
-
Approve: apiblaze
|
|
3507
|
-
console.log(import_chalk29.default.dim(` Dismiss: apiblaze
|
|
3558
|
+
Approve: apiblaze sidecar approve ${candidates[0].origin.replace("https://", "")}`));
|
|
3559
|
+
console.log(import_chalk29.default.dim(` Dismiss: apiblaze sidecar deny ${candidates[0].origin.replace("https://", "")}`));
|
|
3508
3560
|
}
|
|
3509
3561
|
}
|
|
3510
3562
|
async function runOriginsApprove(origin, opts) {
|
|
@@ -3603,7 +3655,7 @@ agent.command("authz").description("Chat to design and turn on access rules for
|
|
|
3603
3655
|
agent.command("openapi").description("Chat to build your API spec from real traffic").argument("<project>", "Project name or id").argument("[apiVersion]", "API version (defaults to the project's)").action(action((project, apiVersion) => runOpenapi(project, apiVersion)));
|
|
3604
3656
|
agent.command("mcp").description("Chat to build an MCP server for an API").argument("<project>", "Project name or id").argument("[apiVersion]", "API version (defaults to the project's)").option("--environment <env>", "Environment to publish (default: prod)").action(action((project, apiVersion, opts) => runMcp(project, apiVersion, opts)));
|
|
3605
3657
|
program.command("init").aliases(["sidecar"]).description("Wire a Next.js app to route its external fetches through APIblaze (one command)").option("--team <id|name>", "Team to set up under (defaults to your active team)").option("--dir <path>", "Project directory (defaults to cwd)").option("--no-inspector", "Skip generating the dev-only /abz-inspector page").option("--rotate", "Mint a fresh invoke key even if one already exists").option("--new-session", "Start a fresh anonymous session (logged-out only)").option("-y, --yes", "Skip prompts").action(action((opts) => runSidecar({ team: opts.team, dir: opts.dir, yes: opts.yes, noInspector: opts.inspector === false, rotate: opts.rotate, newSession: opts.newSession })));
|
|
3606
|
-
var origins = program.command("origins").description("See which external origins your app calls; approve the ones to route through APIblaze").option("--team <id|name>", "Team (defaults to active team)").option("--json", "Machine-readable output").action(action((opts) => runOriginsList(opts)));
|
|
3658
|
+
var origins = program.command("sidecar").alias("origins").description("See which external origins your app calls; approve the ones to route through APIblaze").option("--team <id|name>", "Team (defaults to active team)").option("--json", "Machine-readable output").action(action((opts) => runOriginsList(opts)));
|
|
3607
3659
|
origins.command("approve").description("Route an origin through APIblaze (creates its proxy)").argument("<origin>", "Origin, e.g. api.stripe.com").option("--team <id|name>", "Team (defaults to active team)").option("--json", "Machine-readable output").action(action((origin, opts) => runOriginsApprove(origin, opts)));
|
|
3608
3660
|
origins.command("deny").description("Dismiss a candidate origin so it stops being suggested").argument("<origin>", "Origin, e.g. sentry.io").option("--team <id|name>", "Team (defaults to active team)").action(action((origin, opts) => runOriginsDeny(origin, opts)));
|
|
3609
3661
|
origins.command("remove").description("Un-route an approved origin (deletes its proxy; the app goes direct again)").argument("<origin>", "Origin, e.g. api.stripe.com").option("--team <id|name>", "Team (defaults to active team)").action(action((origin, opts) => runOriginsRemove(origin, opts)));
|
|
@@ -3684,7 +3736,7 @@ spec.command("get").description("Print the current OpenAPI document").argument("
|
|
|
3684
3736
|
spec.command("set").description("Replace the stored OpenAPI spec from a local file").argument("<project>", "Project name or id").requiredOption("--file <path>", "OpenAPI JSON or YAML file to upload").option("--team <id|name>", "Team the project is in").option("--apiversion <version>", "API version").option("--json", "Output machine-readable JSON").action(action((project, opts) => runSpecSet(project, opts)));
|
|
3685
3737
|
var HELP_GROUPS = [
|
|
3686
3738
|
{ title: "Chat", commands: ["agent"] },
|
|
3687
|
-
{ title: "Setup", commands: ["login", "create", "init", "
|
|
3739
|
+
{ title: "Setup", commands: ["login", "create", "init", "sidecar", "dev", "claim", "team", "whoami", "logout"] },
|
|
3688
3740
|
{ title: "Control plane commands", commands: ["projects", "tenant", "domain", "delete", "target", "throttle", "rename", "spec", "export"] },
|
|
3689
3741
|
{ title: "Data plane commands", commands: [
|
|
3690
3742
|
{ parent: "consumer", sub: "login" },
|
package/dist/sidecar/index.js
CHANGED
|
@@ -84,14 +84,15 @@ function isPrivateOrLocal(host) {
|
|
|
84
84
|
}
|
|
85
85
|
function register(opts) {
|
|
86
86
|
if (installed) return;
|
|
87
|
+
const quiet = opts?.quiet ?? (process.env.APIBLAZE_SIDECAR_VERBOSE ?? "true").trim().toLowerCase() === "false";
|
|
87
88
|
const off = opts?.enabled === false || opts?.enabled === void 0 && OFF_VALUES.has((process.env.APIBLAZE_SIDECAR ?? "").trim().toLowerCase());
|
|
88
89
|
if (off) {
|
|
89
|
-
if (!
|
|
90
|
+
if (!quiet) console.log("[apiblaze/sidecar] off (APIBLAZE_SIDECAR=off) \u2014 fetches go direct.");
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
const token = opts?.token ?? process.env.APIBLAZE_API_KEY ?? process.env.APIBLAZE_TOKEN;
|
|
93
94
|
if (!token) {
|
|
94
|
-
if (!
|
|
95
|
+
if (!quiet) console.log("[apiblaze/sidecar] off (no APIBLAZE_API_KEY set) \u2014 fetches go direct.");
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
98
|
const original = globalThis.fetch;
|
|
@@ -145,7 +146,7 @@ function register(opts) {
|
|
|
145
146
|
if (base) {
|
|
146
147
|
if (!seen.has(origin)) {
|
|
147
148
|
seen.add(origin);
|
|
148
|
-
if (!
|
|
149
|
+
if (!quiet) console.log(`[apiblaze/sidecar] routed \u2192 ${origin}`);
|
|
149
150
|
}
|
|
150
151
|
const isReq = input instanceof Request;
|
|
151
152
|
const headers = new Headers(isReq ? input.headers : void 0);
|
|
@@ -168,21 +169,21 @@ function register(opts) {
|
|
|
168
169
|
}
|
|
169
170
|
if (!seen.has(origin)) {
|
|
170
171
|
seen.add(origin);
|
|
171
|
-
if (!
|
|
172
|
+
if (!quiet) console.log(`[apiblaze/sidecar] direct (not approved) \u2192 ${origin} \xB7 approve to route it: npx apiblaze sidecar approve ${url.hostname}`);
|
|
172
173
|
reportObserved(origin);
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
} catch (err) {
|
|
178
|
-
if (!
|
|
179
|
+
if (!quiet) console.warn("[apiblaze/sidecar] passthrough after sidecar error:", err?.message);
|
|
179
180
|
}
|
|
180
181
|
return original(input, init);
|
|
181
182
|
};
|
|
182
183
|
wrapped.__apiblaze = true;
|
|
183
184
|
globalThis.fetch = wrapped;
|
|
184
185
|
installed = true;
|
|
185
|
-
if (!
|
|
186
|
+
if (!quiet) console.log("[apiblaze/sidecar] active \u2014 approved origins route through APIblaze; the rest go direct.");
|
|
186
187
|
}
|
|
187
188
|
function withApiblaze(nextConfig = {}) {
|
|
188
189
|
register();
|
package/dist/sidecar/index.mjs
CHANGED
|
@@ -58,14 +58,15 @@ function isPrivateOrLocal(host) {
|
|
|
58
58
|
}
|
|
59
59
|
function register(opts) {
|
|
60
60
|
if (installed) return;
|
|
61
|
+
const quiet = opts?.quiet ?? (process.env.APIBLAZE_SIDECAR_VERBOSE ?? "true").trim().toLowerCase() === "false";
|
|
61
62
|
const off = opts?.enabled === false || opts?.enabled === void 0 && OFF_VALUES.has((process.env.APIBLAZE_SIDECAR ?? "").trim().toLowerCase());
|
|
62
63
|
if (off) {
|
|
63
|
-
if (!
|
|
64
|
+
if (!quiet) console.log("[apiblaze/sidecar] off (APIBLAZE_SIDECAR=off) \u2014 fetches go direct.");
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
const token = opts?.token ?? process.env.APIBLAZE_API_KEY ?? process.env.APIBLAZE_TOKEN;
|
|
67
68
|
if (!token) {
|
|
68
|
-
if (!
|
|
69
|
+
if (!quiet) console.log("[apiblaze/sidecar] off (no APIBLAZE_API_KEY set) \u2014 fetches go direct.");
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
const original = globalThis.fetch;
|
|
@@ -119,7 +120,7 @@ function register(opts) {
|
|
|
119
120
|
if (base) {
|
|
120
121
|
if (!seen.has(origin)) {
|
|
121
122
|
seen.add(origin);
|
|
122
|
-
if (!
|
|
123
|
+
if (!quiet) console.log(`[apiblaze/sidecar] routed \u2192 ${origin}`);
|
|
123
124
|
}
|
|
124
125
|
const isReq = input instanceof Request;
|
|
125
126
|
const headers = new Headers(isReq ? input.headers : void 0);
|
|
@@ -142,21 +143,21 @@ function register(opts) {
|
|
|
142
143
|
}
|
|
143
144
|
if (!seen.has(origin)) {
|
|
144
145
|
seen.add(origin);
|
|
145
|
-
if (!
|
|
146
|
+
if (!quiet) console.log(`[apiblaze/sidecar] direct (not approved) \u2192 ${origin} \xB7 approve to route it: npx apiblaze sidecar approve ${url.hostname}`);
|
|
146
147
|
reportObserved(origin);
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
} catch (err) {
|
|
152
|
-
if (!
|
|
153
|
+
if (!quiet) console.warn("[apiblaze/sidecar] passthrough after sidecar error:", err?.message);
|
|
153
154
|
}
|
|
154
155
|
return original(input, init);
|
|
155
156
|
};
|
|
156
157
|
wrapped.__apiblaze = true;
|
|
157
158
|
globalThis.fetch = wrapped;
|
|
158
159
|
installed = true;
|
|
159
|
-
if (!
|
|
160
|
+
if (!quiet) console.log("[apiblaze/sidecar] active \u2014 approved origins route through APIblaze; the rest go direct.");
|
|
160
161
|
}
|
|
161
162
|
function withApiblaze(nextConfig = {}) {
|
|
162
163
|
register();
|
package/package.json
CHANGED