@steadphast/connector-nextjs 0.5.2 → 0.5.4

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.
Files changed (2) hide show
  1. package/README.md +227 -70
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  The Next.js connector for [Steadphast](https://steadphast.ai). It runs in your Next.js Middleware
4
4
  (Next.js 15) or Proxy (Next.js 16), captures request metadata before the request reaches your
5
- application, and sends one sanitized evidence envelope per request to Steadphast in the background.
5
+ application, and sends a bounded, sanitized record of each request to Steadphast in the background.
6
6
  Steadphast classifies the traffic server-side: the connector never reads a request body, never runs
7
7
  any classification, and never changes the response your visitor receives.
8
8
 
9
+ The package is one connector with two modes: **Next.js on Vercel** (`kind: "vercel"`) and
10
+ **Next.js self-hosted** (`kind: "self-hosted"`).
11
+
9
12
  ```text
10
13
  Visitor / bot Your Next.js deployment Steadphast
11
14
  ───────────── ─────────────────────── ──────────
@@ -15,8 +18,8 @@ any classification, and never changes the response your visitor receives.
15
18
  │ │ 2. read method, URL, headers only │
16
19
  │ │ 3. drop recognized credential headers │
17
20
  │ │ + your excludedHeaders │
18
- │ │ 4. build one bounded envelope │
19
- │ │ 5. waitUntil(POST envelope) ─────────►│ classify
21
+ │ │ 4. build one bounded record │
22
+ │ │ 5. waitUntil(POST record) ───────────►│ classify
20
23
  │ │ 6. run your handler, then the app │ + store
21
24
  │◄───────────────────────────────┤ response (unchanged by the connector) │
22
25
  │ │ │
@@ -28,16 +31,13 @@ authoritative terms.
28
31
 
29
32
  ## Requirements
30
33
 
31
- - Next.js 15 or 16. Next.js is the only peer dependency (`^15.0.0 || ^16.0.0`), so the package
32
- installs against the Next.js version your application already pins. The tested and supported
33
- versions are Next.js **15.5.23** (`middleware.ts`) and **16.3.2** (`proxy.ts`); other releases on
34
- those two lines are expected to work. Next.js 14 and earlier are not supported.
34
+ - Next.js 15 and 16. Next.js is the only peer dependency (`^15.0.0 || ^16.0.0`), so the package
35
+ installs against the Next.js version your application already pins. Tested with Next.js 15.5.23
36
+ (`middleware.ts`) and 16.3.2 (`proxy.ts`); other releases on those two lines are expected to
37
+ work. Next.js 14 and earlier are not supported.
35
38
  - A Steadphast API key, created in the dashboard under **Settings → API keys** with **Used with**
36
- set to the mode you deploy: **Vercel Routing Middleware** or **Self-hosted Next.js**. A key issued
37
- for one mode is rejected by the other.
38
- - Version **0.5.1 or later** of this package, the first version published under this name. The
39
- earlier `@discover/connector-nextjs` package (0.5.0 and older) is retired; see
40
- [Upgrading](#upgrading).
39
+ set to the mode you deploy: **Next.js on Vercel** or **Next.js self-hosted**. A key is issued for
40
+ one deployment mode and is rejected by the other.
41
41
 
42
42
  ## Install
43
43
 
@@ -55,7 +55,52 @@ The package has no runtime dependencies; install no other Steadphast package. On
55
55
  earlier, `npm install` stops with `ERESOLVE` and `pnpm add` warns about an unmet peer: upgrade
56
56
  Next.js rather than forcing the install.
57
57
 
58
- ## Quick start on Vercel
58
+ ## Let a coding agent do the setup
59
+
60
+ If a coding agent (Claude Code, Codex, Cursor, or similar) has access to your application's
61
+ repository, paste the prompt for your deployment mode into it. The prompt sends the agent to this
62
+ README, has it install the package, write the entry file, propose the routes to exclude from
63
+ capture, and run the build, and it stops before anything that needs your account: it never creates,
64
+ asks for, or writes an API key, and it does not deploy. Review the routes it excluded before you
65
+ deploy. In the self-hosted prompt, replace `https://www.example.com` and `www.example.com` with
66
+ your public origin and host first.
67
+
68
+ ### Prompt: Next.js on Vercel
69
+
70
+ ```text
71
+ Integrate the Steadphast Next.js connector into this application. The site is deployed on Vercel.
72
+
73
+ The integration guide is the package README. Follow it exactly and do not invent configuration options it does not document.
74
+
75
+ Steps:
76
+ 1. Before installing anything, check the Next.js version in package.json. The connector supports Next.js 15 (entry file middleware.ts) and Next.js 16 (entry file proxy.ts). If the app is on an older version, stop and tell me; do not upgrade Next.js.
77
+ 2. Install @steadphast/connector-nextjs with the package manager this repo already uses, then read node_modules/@steadphast/connector-nextjs/README.md in full before changing anything. If your package manager does not create node_modules, print the README with: npm view @steadphast/connector-nextjs readme
78
+ 3. Create the entry file for our Next.js version beside the app or pages directory (or under src/ if the app lives there). Default-export withDiscover with kind: "vercel", apiUrl: "https://api.steadphast.ai", excludedHeaders: ["cookie"], and a recordIdPrefix that names this deployment. Export a config with a matcher that excludes _next/static, _next/image, favicon.ico, and every route that handles form submissions, authentication, payments, or other sensitive actions in this app. List the routes you excluded and why so I can review them.
79
+ 4. Run the production build and fix any errors. Do not start a dev server.
80
+ 5. Do not deploy. Do not create, request, or write an API key anywhere; never put a key in a file or in a NEXT_PUBLIC_ variable. I will generate the key in Steadphast under Settings, API keys, with "Used with" set to "Next.js on Vercel", and set STEADPHAST_API_KEY in the Vercel project's environment myself.
81
+
82
+ Finish with a short handoff that tells me: the files you changed, the routes excluded from capture, the exact remaining manual steps (set the variable, redeploy), and how to verify: request the production domain with an AI crawler user agent, for example curl -A GPTBot, then check Explore in the Steadphast dashboard, which shows AI traffic by default.
83
+ ```
84
+
85
+ ### Prompt: Next.js self-hosted
86
+
87
+ ```text
88
+ Integrate the Steadphast Next.js connector into this application in self-hosted mode. The site runs with next start on our own server behind nginx, and visitors reach it at https://www.example.com.
89
+
90
+ The integration guide is the package README. Follow it exactly and do not invent configuration options it does not document.
91
+
92
+ Steps:
93
+ 1. Before installing anything, check the Next.js version in package.json. The connector supports Next.js 15 (entry file middleware.ts, which must also export runtime: "nodejs" in its config) and Next.js 16 (entry file proxy.ts, which takes no runtime option). If the app is on an older version, stop and tell me; do not upgrade Next.js.
94
+ 2. Install @steadphast/connector-nextjs with the package manager this repo already uses, then read node_modules/@steadphast/connector-nextjs/README.md in full before changing anything. If your package manager does not create node_modules, print the README with: npm view @steadphast/connector-nextjs readme
95
+ 3. Create the entry file for our Next.js version beside the app or pages directory (or under src/ if the app lives there). Default-export withDiscover with kind: "self-hosted", publicOrigin: "https://www.example.com", apiUrl: "https://api.steadphast.ai", excludedHeaders: ["cookie"], and a recordIdPrefix that names this deployment. Export a config with a matcher that excludes _next/static, _next/image, favicon.ico, and every route that handles form submissions, authentication, payments, or other sensitive actions in this app. List the routes you excluded and why so I can review them.
96
+ 4. Run the production build and fix any errors. Do not start a dev server. On Next.js 15 with runtime: "nodejs", the build output shows no Middleware line and .next/server/middleware-manifest.json stays empty; that is expected. The middleware is registered in .next/server/functions-config-manifest.json instead. Keep runtime: "nodejs".
97
+ 5. Copy the reference nginx configuration from the README's Next.js self-hosted section into deploy/nginx/nginx.conf and change only the values its table lists: the public host and port (www.example.com on 443, in every occurrence, keeping the [.] spelling inside the map regular expression), the certificate paths, and the proxy_pass listener (127.0.0.1:39515). Keep every other directive exactly as written; it is what sets X-Steadphast-Client-Ip from $remote_addr and X-Steadphast-Request-Id from $request_id on every proxied request and answers 421 to any other host. Do not run nginx, systemctl, certbot, or sudo, and do not connect to any server; I will apply this on the host.
98
+ 6. Do not deploy. Do not create, request, or write an API key anywhere; never put a key in a file or in a NEXT_PUBLIC_ variable. I will generate the key in Steadphast under Settings, API keys, with "Used with" set to "Next.js self-hosted", and set STEADPHAST_API_KEY in the environment of the next start process myself.
99
+
100
+ Finish with a short handoff that tells me: the files you changed, the routes excluded from capture, the exact remaining manual steps on the host (install the nginx config, the key, restart), and how to verify: request the site with an AI crawler user agent, for example curl -A GPTBot, then check Explore in the Steadphast dashboard, which shows AI traffic by default.
101
+ ```
102
+
103
+ ## Quick start: Next.js on Vercel
59
104
 
60
105
  ### Next.js 15: `middleware.ts`
61
106
 
@@ -100,11 +145,19 @@ export const config = {
100
145
  ### Set the API key
101
146
 
102
147
  Add `STEADPHAST_API_KEY` to every Vercel environment where capture should be enabled. It is a
103
- server-only secret: never give it a `NEXT_PUBLIC_*` name. When no key is set, the connector logs a
104
- warning once and ships nothing; the visitor response is unaffected.
105
-
106
- Deploy, make a request to a matched path, and open **Explore** in the Steadphast dashboard. The
107
- event normally appears within about 60 seconds.
148
+ server-only secret: never give it a `NEXT_PUBLIC_*` name. When no key is set, the connector ships
149
+ nothing and the visitor response is unaffected; it logs one warning per running instance, on the
150
+ first matched request that is not a skipped static asset, that begins
151
+ `Steadphast connector skipped event`.
152
+ Look for it in the deployment's runtime logs. Adding the variable takes effect on the next
153
+ deployment, so redeploy after you set it.
154
+
155
+ Deploy, make a request to a matched path on your production domain (deployment-specific
156
+ `*.vercel.app` URLs are protected by Vercel Deployment Protection by default), and open **Explore**
157
+ in the Steadphast dashboard. The event normally appears within about 60 seconds. Explore opens on AI
158
+ traffic only, so a request from your own browser is hidden until you switch the traffic filter to
159
+ all traffic; a request sent with an AI crawler's user agent, such as `curl -A GPTBot`, appears in the
160
+ default view.
108
161
 
109
162
  ### Keep your own Middleware or Proxy logic
110
163
 
@@ -130,13 +183,15 @@ Keep the wrapper as the file's default export so Next.js calls it with both the
130
183
  `NextFetchEvent`; delivery is scheduled through `event.waitUntil`. Do not call the wrapper from a
131
184
  route handler, and do not drop the event argument.
132
185
 
133
- ## Self-hosted Next.js
186
+ ## Next.js self-hosted
134
187
 
135
188
  Self-hosted mode is for a Next.js application started with `next start` on a server, virtual
136
189
  machine, or container you operate, with nginx terminating client TLS directly in front of it. It
137
190
  is the same package configured with `kind: "self-hosted"`. Use it in either entry file; for
138
191
  Next.js 15 `middleware.ts` also add `runtime: "nodejs"` to the exported `config` (Next.js 16
139
- `proxy.ts` is already Node-only and does not accept the `runtime` option).
192
+ `proxy.ts` is already Node-only and does not accept the `runtime` option). The full setup guide is in the
193
+ dashboard at <https://app.steadphast.ai/docs/integrations/nextjs-self-hosted>; the reference nginx
194
+ configuration it uses is reproduced [below](#reference-nginx-configuration).
140
195
 
141
196
  ```ts
142
197
  import { withDiscover } from "@steadphast/connector-nextjs";
@@ -160,7 +215,7 @@ export const config = {
160
215
  of the captured request URL's origin. It must be one HTTPS origin with no credentials, path, query,
161
216
  or fragment, and it must match the public authority nginx serves exactly. It is separate from
162
217
  `apiUrl`. The API key comes from the `STEADPHAST_API_KEY` environment variable of the `next start`
163
- process, issued with **Used with** set to **Self-hosted Next.js**.
218
+ process, issued with **Used with** set to **Next.js self-hosted**.
164
219
 
165
220
  ### The nginx trust boundary
166
221
 
@@ -172,10 +227,9 @@ is reachable without nginx, or a proxy that passes client headers through, lets
172
227
  the IP recorded for its requests.
173
228
 
174
229
  The supported topology is exactly one nginx directly in front of the application, and the
175
- supported configuration is the complete reference `nginx.conf` published in the Steadphast
176
- dashboard under **Docs → Integrations → Self-hosted Next.js**, which Steadphast tests on every
177
- change. Start from that file and change only the values it lists (public host and port,
178
- certificate paths, and the loopback `proxy_pass` address). It:
230
+ supported configuration is the [reference nginx configuration](#reference-nginx-configuration)
231
+ below. Start from that file and change only the values it lists (public host and port, certificate
232
+ paths, and the loopback `proxy_pass` address). It:
179
233
 
180
234
  - terminates client TLS directly on TLS 1.2 or 1.3 and refuses a handshake without the configured
181
235
  server name;
@@ -193,6 +247,131 @@ front of nginx, a public direct Next.js port, and pass-through internal headers
193
247
  the connector cannot detect them, and a CDN in front makes the recorded client IP that CDN's
194
248
  address. No TLS fingerprint is available in this mode.
195
249
 
250
+ ### Reference nginx configuration
251
+
252
+ This is the complete `nginx.conf` Steadphast tests with, reproduced exactly. It replaces the
253
+ distribution's `nginx.conf` and everything it includes from `conf.d` or `sites-enabled` rather than
254
+ being added beside them. Install it as `nginx.conf` in a directory of its own (for example
255
+ `/etc/steadphast/nginx/`) so its relative paths resolve there, check it with
256
+ `nginx -t -p /etc/steadphast/nginx/ -c nginx.conf`, and start nginx as root with
257
+ `nginx -e stderr -p /etc/steadphast/nginx/ -c nginx.conf -g "daemon off;"`. It needs nginx 1.25.1
258
+ or later.
259
+
260
+ ```nginx
261
+ # Steadphast Next.js connector: reference nginx configuration for self-hosted mode.
262
+ #
263
+ # nginx is the only process that terminates client TLS. It accepts exactly one public host,
264
+ # sets the two internal connector headers from facts it established itself, and proxies to a
265
+ # Next.js `next start` listener bound to loopback. The public scheme, host, and port served
266
+ # here must equal the connector's `publicOrigin` exactly. The placeholder host and port used
267
+ # below are replaced with your own; see the values table in the setup guide.
268
+ #
269
+ # This is a complete nginx.conf. Install it as `nginx.conf` inside an explicit prefix so the
270
+ # relative TLS and temp paths resolve there, then run
271
+ # `nginx -e stderr -p <prefix>/ -c nginx.conf -g "daemon off;"`.
272
+ #
273
+ # Trust boundary (do not weaken):
274
+ # * x-steadphast-client-ip <- $remote_addr, the direct TCP peer. Nothing may sit in front
275
+ # of nginx: no CDN and no load balancer.
276
+ # * x-steadphast-request-id <- $request_id, the request identifier nginx generates itself.
277
+ # * Host / X-Forwarded-Host / X-Forwarded-Proto <- the routing and transport facts nginx checked.
278
+ # * X-Forwarded-For <- the client's value plus $remote_addr, kept only as untrusted
279
+ # evidence.
280
+ # * Anything else the client sends (X-Real-IP, x-vercel-*, a public x-request-id, ...) is
281
+ # passed through as ordinary request data; the connector never uses it as the client IP or
282
+ # request ID in self-hosted mode.
283
+
284
+ worker_processes 1;
285
+ pid nginx.pid;
286
+ error_log stderr warn;
287
+
288
+ events {
289
+ worker_connections 1024;
290
+ }
291
+
292
+ http {
293
+ access_log off;
294
+ server_tokens off;
295
+ client_body_temp_path client_body_temp;
296
+ proxy_temp_path proxy_temp;
297
+ fastcgi_temp_path fastcgi_temp;
298
+ uwsgi_temp_path uwsgi_temp;
299
+ scgi_temp_path scgi_temp;
300
+
301
+ # `$request` retains the raw HTTP/1 request-target. Accept origin-form only with exactly one
302
+ # leading slash; an absolute-form target must spell this listener's complete HTTPS authority.
303
+ map $request $steadphast_request_target_ok {
304
+ default 0;
305
+ "~^[^ ]+ /(?:[^/ ][^ ]*)? HTTP/[0-9.]+$" 1;
306
+ "~^[^ ]+ https://connector[.]steadphast[.]test:39516(?:/[^ ]*|[?][^ ]*)? HTTP/[0-9.]+$" 1;
307
+ }
308
+
309
+ # Handshake policy belongs to the shared/default context: nginx selects a virtual server only
310
+ # after the ClientHello, so the default and named handshakes must inherit the same minimum.
311
+ ssl_protocols TLSv1.2 TLSv1.3;
312
+
313
+ # Catch-all: a handshake without the configured SNI is refused outright.
314
+ server {
315
+ listen 39516 ssl default_server;
316
+ server_name _;
317
+ ssl_reject_handshake on;
318
+ return 421;
319
+ }
320
+
321
+ server {
322
+ listen 39516 ssl;
323
+ http2 on;
324
+ server_name connector.steadphast.test;
325
+
326
+ ssl_certificate steadphast/tls.crt;
327
+ ssl_certificate_key steadphast/tls.key;
328
+ ssl_prefer_server_ciphers off;
329
+
330
+ # Require the raw request-target and complete wire authority, then independently check
331
+ # nginx's normalized host. `$host` drops an absolute-form target's port.
332
+ if ($steadphast_request_target_ok = 0) {
333
+ return 421;
334
+ }
335
+ if ($http_host != "connector.steadphast.test:39516") {
336
+ return 421;
337
+ }
338
+ if ($host != "connector.steadphast.test") {
339
+ return 421;
340
+ }
341
+
342
+ location / {
343
+ # The private Next.js listener: `next start -H 127.0.0.1 -p 39515`.
344
+ proxy_pass http://127.0.0.1:39515;
345
+ proxy_http_version 1.1;
346
+ proxy_set_header Connection "";
347
+
348
+ # Validated external facts replace whatever the client sent.
349
+ proxy_set_header Host "connector.steadphast.test:39516";
350
+ proxy_set_header X-Forwarded-Host "connector.steadphast.test:39516";
351
+ proxy_set_header X-Forwarded-Proto "https";
352
+
353
+ # Internal connector headers: always overwritten, never preserved. `proxy_set_header`
354
+ # replaces every client-supplied occurrence, so duplicates cannot leak through.
355
+ proxy_set_header X-Steadphast-Client-Ip $remote_addr;
356
+ proxy_set_header X-Steadphast-Request-Id $request_id;
357
+
358
+ # Untrusted evidence only: the client chain with our direct peer appended.
359
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
360
+ }
361
+ }
362
+ }
363
+ ```
364
+
365
+ The reference is written for a placeholder public host and port and a Next.js listener on loopback. Adapt it by changing only these values and keep every directive. In the `map` block the host is a regular expression, so each dot is written `[.]` to match a literal dot; keep that spelling when you substitute your own host, for example `www[.]example[.]com`:
366
+
367
+ | Reference value | Replace with |
368
+ |---|---|
369
+ | `connector.steadphast.test:39516` (the absolute-form request-target `map`, the `$http_host` check, and both the `proxy_set_header Host` and `X-Forwarded-Host` lines) | Your public authority, identical in every occurrence and identical to `publicOrigin`. On the default port `443` clients send a bare `Host`, so use `www.example.com` with no port in all of these and set `publicOrigin` to `https://www.example.com`; on any other port keep the `host:port` form in all of them and in `publicOrigin` |
370
+ | `connector.steadphast.test` (`server_name` and the `$host` check) | Your public host |
371
+ | `listen 39516 ssl` in both `server` blocks | Your public port |
372
+ | `ssl_certificate` and `ssl_certificate_key` | Your certificate and key paths |
373
+ | `proxy_pass http://127.0.0.1:39515` | The loopback address and port of your `next start` process |
374
+
196
375
  ## Configuration reference
197
376
 
198
377
  ```ts
@@ -212,12 +391,12 @@ type DiscoverNextConfig = (
212
391
  | Option | Required | Description |
213
392
  |---|---|---|
214
393
  | `kind` | Yes | `"vercel"` or `"self-hosted"`. The mode is never inferred from headers, environment variables, host names, or runtime globals. |
215
- | `publicOrigin` | Self-hosted only | The public HTTPS origin nginx serves. See [Self-hosted Next.js](#self-hosted-nextjs). |
216
- | `apiUrl` | Yes | The Steadphast API origin, normally `https://api.steadphast.ai`. See [Destination rules](#destination-rules). |
217
- | `apiKeyEnvVar` | No | Name of the server-only environment variable holding the API key. Defaults to `STEADPHAST_API_KEY`, with `DISCOVER_API_KEY` accepted as a deprecated fallback. When set, only the named variable is read. A `NEXT_PUBLIC_*` name is rejected. |
394
+ | `publicOrigin` | Self-hosted only | The public HTTPS origin nginx serves. See [Next.js self-hosted](#nextjs-self-hosted). |
395
+ | `apiUrl` | Yes | The Steadphast API origin, `https://api.steadphast.ai`. See [Destination rules](#destination-rules). |
396
+ | `apiKeyEnvVar` | No | Name of the server-only environment variable holding the API key. Defaults to `STEADPHAST_API_KEY` (`DISCOVER_API_KEY` is still read as a deprecated fallback; migrate to `STEADPHAST_API_KEY`). When set, only the named variable is read. A `NEXT_PUBLIC_*` name is rejected. |
218
397
  | `captureAllPaths` | No | Static assets (scripts, styles, images, fonts, and similar) are skipped by default, except `robots.txt` and `sitemap.xml`. Set `true` to capture every path the matcher allows. |
219
398
  | `excludedHeaders` | No | Header names (case-insensitive) to remove from the captured header map. Cookies are captured unless you exclude them. |
220
- | `recordIdPrefix` | No | A short label that prefixes the record IDs Steadphast assigns, useful for telling deployments apart. Defaults to `vercel-routing-middleware` or `nextjs-self-hosted`. Must be at most 128 UTF-8 bytes; a longer value is not rejected at startup but makes every capture drop silently. |
399
+ | `recordIdPrefix` | No | A short label that prefixes the record IDs Steadphast assigns, useful for telling deployments apart. Defaults to `vercel-routing-middleware` or `nextjs-self-hosted`. Limit: 128 UTF-8 bytes. A longer value is not rejected at startup but makes every capture drop silently. |
221
400
  | `timeoutMs` | No | Delivery timeout in milliseconds. Defaults to `5000`. |
222
401
 
223
402
  `kind`, `publicOrigin`, `apiUrl`, and the `NEXT_PUBLIC_*` rule for `apiKeyEnvVar` are validated
@@ -243,7 +422,7 @@ and redirects are rejected, so your API key is never sent over plaintext or to a
243
422
 
244
423
  ## What is captured
245
424
 
246
- Each captured request produces one strict JSON envelope containing the deployment mode, capture
425
+ Each captured request produces one strict JSON record containing the deployment mode, capture
247
426
  timestamp, your `recordIdPrefix`, request metadata, and platform metadata:
248
427
 
249
428
  - **Request:** method, URL, and headers. The connector reads nothing else. It never reads, clones,
@@ -296,13 +475,12 @@ every credential-bearing name in `excludedHeaders`.
296
475
 
297
476
  Other headers, including cookies, are captured by default, so exclude them explicitly wherever that
298
477
  is not acceptable. Excluding a header removes it from the generic header map only; it does not
299
- remove a value that a dedicated envelope field separately carries (for example the user agent).
300
- Query strings can contain sensitive values, so avoid placing secrets or personal data in public
301
- URLs.
478
+ remove a value that a dedicated field separately carries (for example the user agent). Query
479
+ strings can contain sensitive values, so avoid placing secrets or personal data in public URLs.
302
480
 
303
481
  ### Size limits
304
482
 
305
- Every per-field, per-header, header-count, and whole-envelope limit is enforced before anything is
483
+ Every per-field, per-header, header-count, and whole-record limit is enforced before anything is
306
484
  sent. A value that cannot be represented exactly is either omitted, when omission preserves
307
485
  meaning, or the whole observation is dropped. Nothing is ever truncated and presented as observed
308
486
  data.
@@ -314,17 +492,20 @@ timeout. There is no batching, no retry, and no client-side queue. A delivery th
314
492
  or is rejected drops that single event, and nothing about the request, response, or credential is
315
493
  logged.
316
494
 
317
- Delivery does not block the visitor response: the connector serializes the envelope, schedules the
495
+ Delivery does not block the visitor response: the connector serializes the record, schedules the
318
496
  `POST` through `waitUntil`, and then calls your handler. A drop, timeout, or rejection never
319
497
  changes the response status, headers, or body, and never propagates an error into your composed
320
498
  handler.
321
499
 
322
500
  ## Troubleshooting
323
501
 
324
- - **No events appear:** confirm the API key's **Used with** label matches the configured `kind`,
325
- that `STEADPHAST_API_KEY` is set in the deployed environment, that the entry file default-exports
326
- the wrapper, that `recordIdPrefix` is within 128 bytes, and that the matcher or static-asset
327
- filter did not skip the path.
502
+ - **No events appear:** switch the Explore traffic filter to all traffic first, because the default
503
+ view shows AI traffic only. Then confirm the API key was issued for the mode you set in `kind`
504
+ (**Next.js on Vercel** or **Next.js self-hosted**), that `STEADPHAST_API_KEY` is set in the
505
+ deployed environment and the process or deployment was restarted after you set it, that the entry
506
+ file default-exports the wrapper, that `recordIdPrefix` is within its 128-byte limit, and that the
507
+ matcher or static-asset filter did not skip the path. A `Steadphast connector skipped event` line
508
+ in the runtime logs means no key reached the process.
328
509
  - **The deployment fails at startup:** `apiUrl` is not HTTPS or its path is neither `/` nor
329
510
  `/v1/connectors/nextjs/events`, `publicOrigin` is not a bare HTTPS origin, or `apiKeyEnvVar`
330
511
  names a `NEXT_PUBLIC_*` variable. The thrown `DiscoverConfigError` names the setting.
@@ -332,8 +513,9 @@ handler.
332
513
  are captured, so a plain `http://localhost` server never ships. Front the server with an HTTPS
333
514
  proxy or send `X-Forwarded-Proto: https`, which Next.js honors when building the request URL.
334
515
  - **Self-hosted events have no client IP:** nginx is not overwriting `X-Steadphast-Client-Ip`, or
335
- the request bypassed nginx. Compare your configuration with the reference in the dashboard guide
336
- and confirm the Next.js port is not reachable from outside.
516
+ the request bypassed nginx. Compare your configuration with the
517
+ [reference nginx configuration](#reference-nginx-configuration) and confirm the Next.js port is
518
+ not reachable from outside.
337
519
  - **Self-hosted requests answer `421`:** nginx received a `Host` or absolute-form request target
338
520
  that does not match its configured public authority. Make the `server_name`, the `Host` checks,
339
521
  the `proxy_set_header Host` lines, and `publicOrigin` agree with each other.
@@ -346,37 +528,12 @@ handler.
346
528
 
347
529
  ## Upgrading
348
530
 
531
+ - **0.5.4** Documentation only: this README now carries the reference nginx configuration and the
532
+ coding-agent setup prompts; no runtime change.
533
+ - **0.5.3** Documentation and metadata only; no runtime change.
349
534
  - **0.5.2** changes documentation and package metadata only; the shipped code is identical to
350
535
  0.5.1, and no upgrade action is needed.
351
- - **0.5.1** is the first version published as `@steadphast/connector-nextjs`. Deployments on the
352
- retired `@discover/connector-nextjs` package (0.5.0 and older) must replace the dependency and
353
- the import specifier; the `withDiscover` API and configuration are otherwise unchanged from
354
- 0.5.0.
355
- - **0.5.0** sends envelope version 2, the only version the Steadphast API accepts. Deployments on
356
- 0.4.x or earlier must upgrade; their envelopes are rejected.
357
- - **0.4.0** changed the public API: `withDiscover` requires an explicit `kind` and `apiUrl`; the
358
- package root exports `withDiscover`, its configuration types, `DiscoverConfigError`, the two
359
- connector-assertion constants, and the two self-hosted header-name constants, and nothing else;
360
- and `apiUrl` must target the connector endpoint described under
361
- [Destination rules](#destination-rules).
362
-
363
- ## Developing this package
364
-
365
- The source lives in the Steadphast repository at `ts/packages/connector-nextjs`, next to the
366
- `@discover/connector-core` package it bundles. The package's whole job is to emit the sanitized
367
- envelope described above; turning that envelope into a Steadphast event, and every enrichment and
368
- classification step, happens only on the Steadphast server, so nothing here depends on or
369
- duplicates the server's event model. Inside the repository, which runs every command through its
370
- Nix development shell:
371
-
372
- ```sh
373
- nix develop -c pnpm -C ts --filter @steadphast/connector-nextjs test
374
- nix develop -c pnpm -C ts --filter @steadphast/connector-nextjs build
375
- ```
376
-
377
- The `DEVELOPMENT.md` beside the source (not shipped in the npm tarball) covers the design
378
- references, the canonical-contract seam, the monorepo build, the release process, and the rollout
379
- history.
536
+ - **0.5.1** is the first published version of this package.
380
537
 
381
538
  ## License
382
539
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@steadphast/connector-nextjs",
3
3
  "description": "Next.js Middleware and Proxy connector for Steadphast: captures request metadata before it reaches your app and sends it to Steadphast for AI and bot traffic classification, without touching the response.",
4
- "version": "0.5.2",
4
+ "version": "0.5.4",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Steadphast",
7
7
  "homepage": "https://steadphast.ai",