You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add Next proxy adapter foundation
- Adds createEmulateProxy with single-target and service-target forwarding, prefix handling, forwarded headers, and response rewriting for native runtimes.
- Keeps embedded Next adapter behavior intact while adding focused proxy tests and adapter test wiring.
- Updates docs and skills to distinguish embedded mode from native runtime proxy mode.
* Fix Next proxy redirect handling
* Fix Next proxy prefix rewriting
* Harden Next proxy response rewriting
Copy file name to clipboardExpand all lines: README.md
+45-3Lines changed: 45 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -713,7 +713,7 @@ The experimental native Go runtime serves the same current Resend routes, suppor
713
713
714
714
## Next.js Integration
715
715
716
-
Embed emulators directly in your Next.js app so they run on the same origin. This solves the Vercel preview deployment problem where OAuth callback URLs change with every deployment.
716
+
Use `@emulators/adapter-next` to run emulator routes on the same origin as your Next.js app. Embedded mode runs JavaScript emulators directly in the app. Proxy mode forwards to a separately running native runtime.
Embedded mode is the current zero-infra path for Vercel preview deployments. The emulator code runs in the Next.js function, so OAuth callback URLs can point at the preview origin.
756
+
757
+
### Native runtime proxy
758
+
759
+
Use `createEmulateProxy` when a native runtime is running separately and the Next.js route should forward requests to it:
760
+
761
+
```typescript
762
+
// app/emulate/[...path]/route.ts
763
+
import { createEmulateProxy } from '@emulators/adapter-next'
With `targets`, the first path segment selects the service and is stripped before forwarding. `/emulate/resend/emails` forwards to `http://127.0.0.1:4018/emails`, while response `Location` headers and HTML links are rewritten back to `/emulate/resend/*`.
774
+
775
+
If multiple services share one native runtime URL, keep using `targets` and point each service at that runtime when the runtime expects service-local paths:
Single target mode preserves every path segment. `/emulate/aws/sqs` forwards to `http://127.0.0.1:4020/aws/sqs`. For deployed previews, the target URL must be reachable from the Next.js serverless function.
796
+
755
797
### Auth.js / NextAuth configuration
756
798
757
799
Point your provider at the emulator paths on the same origin:
constSYSTEM_PROMPT=`You are a helpful documentation assistant for emulate, a local drop-in replacement for Vercel, GitHub, Google, Slack, Apple, Microsoft, AWS, Okta, MongoDB Atlas, Resend, and Stripe APIs used in CI and no-network sandboxes.
16
16
17
-
emulate provides fully stateful, production-fidelity API emulation, not mocks. The CLI is installed as the "emulate" npm package and run via "npx emulate". It also supports a programmatic API via createEmulator and a Next.js adapter (@emulators/adapter-next) for embedding emulators in your app.
17
+
emulate provides fully stateful, production-fidelity API emulation, not mocks. The CLI is installed as the "emulate" npm package and run via "npx emulate". It also supports a programmatic API via createEmulator and a Next.js adapter (@emulators/adapter-next) for embedded emulators or native runtime proxy routes in your app.
18
18
19
19
You have access to the full emulate documentation via the bash and readFile tools. The docs are available as markdown files in the /workspace/ directory.
Copy file name to clipboardExpand all lines: apps/web/app/docs/nextjs/page.mdx
+47-3Lines changed: 47 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Next.js Integration
2
2
3
-
The `@emulators/adapter-next` package embeds emulators directly into a Next.js app, running them on the same origin. This is particularly useful for Vercel preview deployments where OAuth callback URLs change with every deployment.
3
+
The `@emulators/adapter-next` package supports two App Router modes. Embedded mode runs JavaScript emulators directly inside the Next.js app. Proxy mode exposes a separately running native runtime on the same origin.
Only install the emulators you need. Each `@emulators/*` package is published independently, keeping your serverless bundles small.
12
12
13
-
## Route Handler
13
+
## Embedded Route Handler
14
14
15
-
Create a catch-all route that serves emulator traffic:
15
+
Create a catch-all route that serves emulator traffic in-process:
16
16
17
17
```typescript
18
18
// app/emulate/[...path]/route.ts
@@ -44,6 +44,50 @@ This creates the following routes:
44
44
-`/emulate/github/**` serves the GitHub emulator
45
45
-`/emulate/google/**` serves the Google emulator
46
46
47
+
Embedded mode is the current zero-infra path for Vercel preview deployments. The emulator code runs in the Next.js function, so OAuth callback URLs can point at the preview origin.
48
+
49
+
## Native Runtime Proxy
50
+
51
+
Use `createEmulateProxy` when a native runtime is running separately and the Next.js route should forward requests to it:
With `targets`, the first path segment selects the service and is stripped before forwarding. `/emulate/resend/emails` forwards to `http://127.0.0.1:4018/emails`, while response `Location` headers and HTML links are rewritten back to `/emulate/resend/*`.
66
+
67
+
If multiple services share one native runtime URL, keep using `targets` and point each service at that runtime when the runtime expects service-local paths:
Single target mode preserves every path segment. `/emulate/aws/sqs` forwards to `http://127.0.0.1:4020/aws/sqs`.
88
+
89
+
The proxy adds `x-forwarded-host`, `x-forwarded-proto`, `x-forwarded-port` when known, `x-forwarded-prefix`, `x-emulate-proxy: next`, `x-emulate-original-path`, and `x-emulate-service` for service targets. For deployed previews, the target URL must be reachable from the Next.js serverless function.
90
+
47
91
## Auth.js / NextAuth Configuration
48
92
49
93
Point your provider at the emulator paths on the same origin:
Copy file name to clipboardExpand all lines: apps/web/app/docs/page.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,4 +85,4 @@ You can also use emulate as a library in your tests. See the [Programmatic API](
85
85
86
86
## Next.js Integration
87
87
88
-
Embed emulators directly in your Next.js app so they run on the same origin. See the [Next.js Integration](/docs/nextjs) page for setup instructions.
88
+
Run emulator routes on the same origin as your Next.js app with embedded mode or native runtime proxy mode. See the [Next.js Integration](/docs/nextjs) page for setup instructions.
Copy file name to clipboardExpand all lines: packages/@emulators/adapter-next/README.md
+47-3Lines changed: 47 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# @emulators/adapter-next
2
2
3
-
Next.js App Router integration for emulate. Embed emulators directly in your Next.js app so they run on the same origin, solving the Vercel preview deployment problem where OAuth callback URLs change with every deployment.
3
+
Next.js App Router integration for emulate. Use embedded mode to run JavaScript emulators directly inside your app, or proxy mode to expose a separately running native runtime on the same origin.
4
4
5
5
Part of [emulate](https://github.com/vercel-labs/emulate) — local drop-in replacement services for CI and no-network sandboxes.
6
6
@@ -16,9 +16,9 @@ Only install the emulators you need alongside the adapter:
Embedded mode is the current zero-infra path for Vercel preview deployments. The emulator code runs in the Next.js function, so OAuth callback URLs can point at the preview origin.
49
+
50
+
## Native runtime proxy
51
+
52
+
Use `createEmulateProxy` when a native runtime is running separately and the Next.js route should forward requests to it:
With `targets`, the first path segment selects the service and is stripped before forwarding. `/emulate/resend/emails` forwards to `http://127.0.0.1:4018/emails`, while response `Location` headers and HTML links are rewritten back to `/emulate/resend/*`.
67
+
68
+
If multiple services share one native runtime URL, keep using `targets` and point each service at that runtime when the runtime expects service-local paths:
Single target mode preserves every path segment. `/emulate/aws/sqs` forwards to `http://127.0.0.1:4020/aws/sqs`.
89
+
90
+
The proxy adds `x-forwarded-host`, `x-forwarded-proto`, `x-forwarded-port` when known, `x-forwarded-prefix`, `x-emulate-proxy: next`, `x-emulate-original-path`, and `x-emulate-service` for service targets. For deployed previews, the target URL must be reachable from the Next.js serverless function.
91
+
48
92
## Auth.js / NextAuth configuration
49
93
50
94
Point your provider at the emulator paths on the same origin:
0 commit comments