@opennextjs/cloudflare 0.0.0-5105d31 → 0.0.0-59a1d9e
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import NextNodeServer, { NodeRequestHandler } from "next/dist/server/next-server";
|
|
2
1
|
import { NodeNextRequest, NodeNextResponse } from "next/dist/server/base-http/node";
|
|
3
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
3
|
import { type CloudflareContext } from "../../api";
|
|
5
4
|
import type { IncomingMessage } from "node:http";
|
|
6
5
|
import { MockedResponse } from "next/dist/server/lib/mock-request";
|
|
7
6
|
import type { NextConfig } from "next";
|
|
7
|
+
import { type NodeRequestHandler } from "next/dist/server/next-server";
|
|
8
8
|
import Stream from "node:stream";
|
|
9
9
|
|
|
10
10
|
const NON_BODY_RESPONSES = new Set([101, 204, 205, 304]);
|
|
@@ -35,6 +35,12 @@ export default {
|
|
|
35
35
|
return cloudflareContextALS.run({ env, ctx, cf: request.cf }, async () => {
|
|
36
36
|
if (requestHandler == null) {
|
|
37
37
|
globalThis.process.env = { ...globalThis.process.env, ...env };
|
|
38
|
+
// Note: "next/dist/server/next-server" is a cjs module so we have to `require` it not to confuse esbuild
|
|
39
|
+
// (since esbuild can run in projects with different module resolutions)
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
41
|
+
const NextNodeServer = require("next/dist/server/next-server")
|
|
42
|
+
.default as typeof import("next/dist/server/next-server").default;
|
|
43
|
+
|
|
38
44
|
requestHandler = new NextNodeServer({
|
|
39
45
|
conf: { ...nextConfig, env },
|
|
40
46
|
customServer: false,
|
|
@@ -58,7 +64,7 @@ export default {
|
|
|
58
64
|
|
|
59
65
|
const { req, res, webResponse } = getWrappedStreams(request, ctx);
|
|
60
66
|
|
|
61
|
-
ctx.waitUntil(requestHandler(new NodeNextRequest(req), new NodeNextResponse(res)));
|
|
67
|
+
ctx.waitUntil(requestHandler!(new NodeNextRequest(req), new NodeNextResponse(res)));
|
|
62
68
|
|
|
63
69
|
return await webResponse();
|
|
64
70
|
});
|
package/package.json
CHANGED