react-router-hono-server 2.3.0 → 2.4.0
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.
package/dist/adapters/bun.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bindIncomingRequestSocketInfo,
|
|
2
3
|
cleanUpgradeListeners,
|
|
3
4
|
createWebSocket,
|
|
4
5
|
patchUpgradeListener
|
|
5
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-D4WESSFB.js";
|
|
6
7
|
import {
|
|
7
8
|
cache
|
|
8
9
|
} from "../chunk-V3H4JZ4H.js";
|
|
@@ -27,6 +28,9 @@ async function createHonoServer(options) {
|
|
|
27
28
|
app,
|
|
28
29
|
enabled: mergedOptions.useWebSocket ?? false
|
|
29
30
|
});
|
|
31
|
+
if (!PRODUCTION) {
|
|
32
|
+
app.use(bindIncomingRequestSocketInfo());
|
|
33
|
+
}
|
|
30
34
|
app.use(
|
|
31
35
|
`/${import.meta.env.REACT_ROUTER_HONO_SERVER_ASSETS_DIR}/*`,
|
|
32
36
|
cache(60 * 60 * 24 * 365),
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bindIncomingRequestSocketInfo
|
|
3
|
+
} from "../chunk-D4WESSFB.js";
|
|
1
4
|
import {
|
|
2
5
|
cache
|
|
3
6
|
} from "../chunk-V3H4JZ4H.js";
|
|
@@ -18,6 +21,7 @@ async function createHonoServer(options) {
|
|
|
18
21
|
if (DEV) {
|
|
19
22
|
const { serveStatic } = await import("@hono/node-server/serve-static");
|
|
20
23
|
app.use("*", cache(60 * 60), serveStatic({ root: "./public" }));
|
|
24
|
+
app.use(bindIncomingRequestSocketInfo());
|
|
21
25
|
}
|
|
22
26
|
if (mergedOptions.defaultLogger) {
|
|
23
27
|
app.use("*", logger());
|
package/dist/adapters/node.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bindIncomingRequestSocketInfo,
|
|
2
3
|
cleanUpgradeListeners,
|
|
3
4
|
createWebSocket,
|
|
4
5
|
patchUpgradeListener
|
|
5
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-D4WESSFB.js";
|
|
6
7
|
import {
|
|
7
8
|
cache
|
|
8
9
|
} from "../chunk-V3H4JZ4H.js";
|
|
@@ -32,6 +33,9 @@ async function createHonoServer(options) {
|
|
|
32
33
|
app,
|
|
33
34
|
enabled: mergedOptions.useWebSocket ?? false
|
|
34
35
|
});
|
|
36
|
+
if (!PRODUCTION) {
|
|
37
|
+
app.use(bindIncomingRequestSocketInfo());
|
|
38
|
+
}
|
|
35
39
|
app.use(
|
|
36
40
|
`/${import.meta.env.REACT_ROUTER_HONO_SERVER_ASSETS_DIR}/*`,
|
|
37
41
|
cache(60 * 60 * 24 * 365),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/helpers.ts
|
|
2
|
+
import { createMiddleware } from "hono/factory";
|
|
2
3
|
var defaultWebSocket = {
|
|
3
4
|
upgradeWebSocket: () => async () => {
|
|
4
5
|
},
|
|
@@ -63,9 +64,24 @@ function patchUpgradeListener(httpServer) {
|
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
}
|
|
67
|
+
function bindIncomingRequestSocketInfo() {
|
|
68
|
+
return createMiddleware(async (c, next) => {
|
|
69
|
+
c.env.server = {
|
|
70
|
+
incoming: {
|
|
71
|
+
socket: {
|
|
72
|
+
remoteAddress: c.req.raw.headers.get("x-remote-address") || void 0,
|
|
73
|
+
remotePort: Number(c.req.raw.headers.get("x-remote-port")) || void 0,
|
|
74
|
+
remoteFamily: c.req.raw.headers.get("x-remote-family") || void 0
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return next();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
66
81
|
|
|
67
82
|
export {
|
|
68
83
|
createWebSocket,
|
|
69
84
|
cleanUpgradeListeners,
|
|
70
|
-
patchUpgradeListener
|
|
85
|
+
patchUpgradeListener,
|
|
86
|
+
bindIncomingRequestSocketInfo
|
|
71
87
|
};
|
package/dist/dev.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import honoDevServer from "@hono/vite-dev-server";
|
|
5
5
|
import bunAdapter from "@hono/vite-dev-server/bun";
|
|
6
6
|
import cloudflareAdapter from "@hono/vite-dev-server/cloudflare";
|
|
7
|
+
import nodeAdapter from "@hono/vite-dev-server/node";
|
|
7
8
|
var virtualModuleId = "\0virtual:react-router-hono-server/server";
|
|
8
9
|
function reactRouterHonoServer(options = {}) {
|
|
9
10
|
const runtime = options.runtime || "node";
|
|
@@ -87,7 +88,7 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
87
88
|
if (devServerPlugin) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
let adapter;
|
|
91
|
+
let adapter = nodeAdapter;
|
|
91
92
|
if (runtime === "bun") {
|
|
92
93
|
adapter = bunAdapter;
|
|
93
94
|
}
|
|
@@ -108,6 +109,12 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
108
109
|
...pluginConfig.dev?.exclude || []
|
|
109
110
|
]
|
|
110
111
|
});
|
|
112
|
+
server.middlewares.use((req, _res, next) => {
|
|
113
|
+
req.rawHeaders.push("x-remote-address", req.socket.remoteAddress || "unknown");
|
|
114
|
+
req.rawHeaders.push("x-remote-port", String(req.socket.remotePort || "unknown"));
|
|
115
|
+
req.rawHeaders.push("x-remote-family", req.socket.remoteFamily || "unknown");
|
|
116
|
+
next();
|
|
117
|
+
});
|
|
111
118
|
if (typeof devServerPlugin.configureServer === "function") {
|
|
112
119
|
devServerPlugin.configureServer(server);
|
|
113
120
|
} else {
|