Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 6b6324b

Browse files
committed
fix(next-js): fix auto-configure in prod (#1385)
1 parent 6abf62d commit 6b6324b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

packages/next-js/src/log.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getLogger } from "rivetkit/log";
2+
3+
export function logger() {
4+
return getLogger("driver-next-js");
5+
}

packages/next-js/src/mod.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Registry, RunConfigInput } from "rivetkit";
2+
import { logger } from "./log";
23

34
export const toNextHandler = (
45
registry: Registry<any>,
@@ -12,6 +13,10 @@ export const toNextHandler = (
1213

1314
// Auto-configure serverless runner if not in prod
1415
if (process.env.NODE_ENV !== "production") {
16+
logger().debug(
17+
"detected development environment, auto-starting engine and auto-configuring serverless",
18+
);
19+
1520
const publicUrl =
1621
process.env.NEXT_PUBLIC_SITE_URL ??
1722
process.env.NEXT_PUBLIC_VERCEL_URL ??
@@ -21,6 +26,10 @@ export const toNextHandler = (
2126
inputConfig.autoConfigureServerless = {
2227
url: `${publicUrl}/api/rivet/start`,
2328
};
29+
} else {
30+
logger().debug(
31+
"detected production environment, will not auto-start engine and auto-configure serverless",
32+
);
2433
}
2534

2635
// Next logs this on every request

packages/rivetkit/src/drivers/default.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export function chooseDefaultDriver(runConfig: RunnerConfig): DriverConfig {
1818
return runConfig.driver;
1919
}
2020

21-
if (runConfig.endpoint || runConfig.token) {
21+
if (
22+
runConfig.endpoint ||
23+
runConfig.token ||
24+
runConfig.runnerKind === "serverless"
25+
) {
2226
loggerWithoutContext().debug({
2327
msg: "using rivet engine driver",
2428
endpoint: runConfig.endpoint,

0 commit comments

Comments
 (0)