Skip to content

Commit 5b1b8cf

Browse files
committed
chdir
1 parent 3c0b07d commit 5b1b8cf

File tree

1 file changed

+5
-6
lines changed
  • packages/@apphosting/adapter-nextjs/src/bin

1 file changed

+5
-6
lines changed

packages/@apphosting/adapter-nextjs/src/bin/serve.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { PassThrough } from "node:stream";
1515

1616
// The standalone directory is the root of the Next.js application.
1717
const dir = join(process.cwd(), process.argv[2] || ".next/standalone");
18+
process.chdir(dir);
1819

1920
// Standard NodeJS HTTP server port and hostname.
2021
const port = parseInt(process.env.PORT!, 10) || 3000
@@ -112,9 +113,8 @@ async function requestHandle(req: IncomingMessage, res: ServerResponse) {
112113
const isPPR = req.url === "/";
113114
if (isPPR) {
114115
/**
115-
* This is a critical interception. The Next.js server (`getRequestHandler`)
116-
* takes full control of the `ServerResponse` object and doesn't provide
117-
* a simple "beforeWrite" hook.
116+
* Next.js uses a request handler (`getRequestHandler`) which takes full
117+
* `ServerResponse` object and doesn't provide any lifecycle hook.
118118
*
119119
* To inject our `x-fah-postponed` header *before* Next.js sends the
120120
* first body chunk, we must monkey-patch `res.write` and `res.end`.
@@ -182,7 +182,6 @@ await grpcServer.register(fastifyConnectPlugin, {
182182
return undefined;
183183
}
184184
for await (const callout of callouts) {
185-
console.log(callout);
186185
switch (callout.request.case) {
187186
case "requestHeaders": {
188187
requestHeaders = callout.request.value.headers?.headers || [];
@@ -386,8 +385,8 @@ await grpcServer.register(fastifyConnectPlugin, {
386385
/**
387386
* -------------------- Full-Duplex Mode ----------------------
388387
*
389-
* Because we're using `streamedResponse` later (for PPR), we are
390-
* we've configured Envoy for full-duplex streaming mode.
388+
* Because we're using `streamedResponse` later (for PPR), we've
389+
* configured Envoy for full-duplex streaming mode.
391390
*
392391
* In this mode, Envoy *always* expects us to send `streamedResponse`
393392
* mutations. If we just `yield` a simple `CONTINUE` (our fallback)

0 commit comments

Comments
 (0)