fix: allow hostname passthrough for hono node
This commit is contained in:
parent
03acebb23e
commit
5918d0e501
2
.npmrc
2
.npmrc
@ -1,2 +1,2 @@
|
|||||||
side-effects-cache = false
|
side-effects-cache = false
|
||||||
public-hoist-pattern[]=hono
|
public-hoist-pattern[]=*hono*
|
||||||
|
|||||||
@ -43,9 +43,10 @@ export interface EnvOverrides {
|
|||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function configureConfig(
|
export function configureConfig(overrides: {
|
||||||
overrides: Partial<EnvOverrides>,
|
loadEnv: string | undefined;
|
||||||
): EnvOverrides {
|
path: string | undefined;
|
||||||
|
}): EnvOverrides {
|
||||||
const loadResult = booleanEnv(overrides.loadEnv);
|
const loadResult = booleanEnv(overrides.loadEnv);
|
||||||
if (loadResult instanceof type.errors) {
|
if (loadResult instanceof type.errors) {
|
||||||
log.error(
|
log.error(
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { env, versions } from 'node:process';
|
import { constants, access } from 'node:fs/promises';
|
||||||
|
import { env, exit, versions } from 'node:process';
|
||||||
import type { UpgradeWebSocket } from 'hono/ws';
|
import type { UpgradeWebSocket } from 'hono/ws';
|
||||||
import { createHonoServer } from 'react-router-hono-server/node';
|
import { createHonoServer } from 'react-router-hono-server/node';
|
||||||
import type { WebSocket } from 'ws';
|
import type { WebSocket } from 'ws';
|
||||||
@ -19,6 +20,13 @@ declare global {
|
|||||||
// MARK: Side-Effects
|
// MARK: Side-Effects
|
||||||
// This module contains a side-effect because everything running here
|
// This module contains a side-effect because everything running here
|
||||||
// exists for the lifetime of the process, making it appropriate.
|
// exists for the lifetime of the process, making it appropriate.
|
||||||
|
try {
|
||||||
|
await access('./node_modules/react-router', constants.F_OK | constants.R_OK);
|
||||||
|
} catch {
|
||||||
|
log.error('server', 'Cannot locate `node_modules`, please install them');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
log.info('server', 'Running Node.js %s', versions.node);
|
log.info('server', 'Running Node.js %s', versions.node);
|
||||||
configureLogger(env[envVariables.debugLog]);
|
configureLogger(env[envVariables.debugLog]);
|
||||||
const config = await loadConfig(
|
const config = await loadConfig(
|
||||||
@ -67,7 +75,9 @@ declare module 'react-router' {
|
|||||||
|
|
||||||
export default await createHonoServer({
|
export default await createHonoServer({
|
||||||
useWebSocket: true,
|
useWebSocket: true,
|
||||||
// overrideGlobalObjects: true,
|
overrideGlobalObjects: true,
|
||||||
|
port: config.server.port,
|
||||||
|
hostname: config.server.host,
|
||||||
|
|
||||||
getLoadContext(c, { build, mode }) {
|
getLoadContext(c, { build, mode }) {
|
||||||
// This is the place where we can handle reverse proxy translation
|
// This is the place where we can handle reverse proxy translation
|
||||||
@ -89,6 +99,6 @@ export default await createHonoServer({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
listeningListener(info) {
|
listeningListener(info) {
|
||||||
console.log(`Server is listening on http://localhost:${info.port}`);
|
log.info('server', 'Running on %s:%s', info.address, info.port);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
|
import { HeadplaneConfig } from '~/server/config/schema';
|
||||||
import log from '~/utils/log';
|
import log from '~/utils/log';
|
||||||
import { hp_getConfig } from '~server/context/global';
|
|
||||||
import type { HeadplaneConfig } from '~server/context/parser';
|
|
||||||
import { Integration } from './abstract';
|
import { Integration } from './abstract';
|
||||||
// import dockerIntegration from './docker';
|
// import dockerIntegration from './docker';
|
||||||
// import kubernetesIntegration from './kubernetes';
|
// import kubernetesIntegration from './kubernetes';
|
||||||
@ -66,5 +65,5 @@ function getIntegration(integration: HeadplaneConfig['integration']) {
|
|||||||
|
|
||||||
// IMPORTANT THIS IS A SIDE EFFECT ON INIT
|
// IMPORTANT THIS IS A SIDE EFFECT ON INIT
|
||||||
// TODO: Switch this to the new singleton system
|
// TODO: Switch this to the new singleton system
|
||||||
const context = hp_getConfig();
|
// const context = hp_getConfig();
|
||||||
// hp_loadIntegration(context.integration);
|
// hp_loadIntegration(context.integration);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "react-router build",
|
"build": "react-router build",
|
||||||
"dev": "HEADPLANE_LOAD_ENV_OVERRIDES=true HEADPLANE_CONFIG_PATH=./config.example.yaml p react-router dev",
|
"dev": "HEADPLANE_LOAD_ENV_OVERRIDES=true HEADPLANE_CONFIG_PATH=./config.example.yaml react-router dev",
|
||||||
"start": "node build/server/index.js",
|
"start": "node build/server/index.js",
|
||||||
"typecheck": "tsc"
|
"typecheck": "tsc"
|
||||||
},
|
},
|
||||||
@ -78,7 +78,8 @@
|
|||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@shopify/lang-jsonc@1.0.0": "patches/@shopify__lang-jsonc@1.0.0.patch"
|
"@shopify/lang-jsonc@1.0.0": "patches/@shopify__lang-jsonc@1.0.0.patch",
|
||||||
|
"react-router-hono-server": "patches/react-router-hono-server.patch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
patches/react-router-hono-server.patch
Normal file
27
patches/react-router-hono-server.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
diff --git a/dist/adapters/node.d.ts b/dist/adapters/node.d.ts
|
||||||
|
index 68742808892c1282ccff1e3321167862196d1229..f9a9249e1d1e573018d7ff3d3b967c4a1667d6ca 100644
|
||||||
|
--- a/dist/adapters/node.d.ts
|
||||||
|
+++ b/dist/adapters/node.d.ts
|
||||||
|
@@ -50,6 +50,10 @@ interface HonoNodeServerOptions<E extends Env = BlankEnv> extends HonoServerOpti
|
||||||
|
/**
|
||||||
|
* Callback executed just after `serve` from `@hono/node-server`
|
||||||
|
*/
|
||||||
|
+ /**
|
||||||
|
+ * Customize the hostname of the node server
|
||||||
|
+ */
|
||||||
|
+ hostname?: string;
|
||||||
|
onServe?: (server: ServerType) => void;
|
||||||
|
/**
|
||||||
|
* The Node.js Adapter rewrites the global Request/Response and uses a lightweight Request/Response to improve performance.
|
||||||
|
diff --git a/dist/adapters/node.js b/dist/adapters/node.js
|
||||||
|
index 481dec801537f6ccf7f7a8a8e2294f4b0f20bb7d..0fbc43c3a345b341a08e8179ea0eabfaca62e3b3 100644
|
||||||
|
--- a/dist/adapters/node.js
|
||||||
|
+++ b/dist/adapters/node.js
|
||||||
|
@@ -86,6 +86,7 @@ async function createHonoServer(options) {
|
||||||
|
...app,
|
||||||
|
...mergedOptions.customNodeServer,
|
||||||
|
port: mergedOptions.port,
|
||||||
|
+ hostname: mergedOptions.hostname,
|
||||||
|
overrideGlobalObjects: mergedOptions.overrideGlobalObjects
|
||||||
|
},
|
||||||
|
mergedOptions.listeningListener
|
||||||
@ -8,6 +8,9 @@ patchedDependencies:
|
|||||||
'@shopify/lang-jsonc@1.0.0':
|
'@shopify/lang-jsonc@1.0.0':
|
||||||
hash: 915164bae9a5d47bb0e7edf0cbbc4c7f0fedb1a2f9a5f6ef5c53d8fef6856211
|
hash: 915164bae9a5d47bb0e7edf0cbbc4c7f0fedb1a2f9a5f6ef5c53d8fef6856211
|
||||||
path: patches/@shopify__lang-jsonc@1.0.0.patch
|
path: patches/@shopify__lang-jsonc@1.0.0.patch
|
||||||
|
react-router-hono-server:
|
||||||
|
hash: 3e40672a2de5e41f1467bc15484f757a23322b7df7b9a8b257ab7133e23f95b4
|
||||||
|
path: patches/react-router-hono-server.patch
|
||||||
|
|
||||||
importers:
|
importers:
|
||||||
|
|
||||||
@ -105,7 +108,7 @@ importers:
|
|||||||
version: 7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
version: 7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||||
react-router-hono-server:
|
react-router-hono-server:
|
||||||
specifier: ^2.11.0
|
specifier: ^2.11.0
|
||||||
version: 2.11.0(@react-router/dev@7.4.0(@types/node@22.10.7)(jiti@1.21.7)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(terser@5.39.0)(tsx@4.19.2)(typescript@5.8.2)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0))(yaml@2.7.0))(@types/react@19.0.2)(bufferutil@4.0.9)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(utf-8-validate@5.0.10)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0))
|
version: 2.11.0(patch_hash=3e40672a2de5e41f1467bc15484f757a23322b7df7b9a8b257ab7133e23f95b4)(@react-router/dev@7.4.0(@types/node@22.10.7)(jiti@1.21.7)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(terser@5.39.0)(tsx@4.19.2)(typescript@5.8.2)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0))(yaml@2.7.0))(@types/react@19.0.2)(bufferutil@4.0.9)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(utf-8-validate@5.0.10)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0))
|
||||||
react-stately:
|
react-stately:
|
||||||
specifier: ^3.35.0
|
specifier: ^3.35.0
|
||||||
version: 3.35.0(react@19.0.0)
|
version: 3.35.0(react@19.0.0)
|
||||||
@ -6240,7 +6243,7 @@ snapshots:
|
|||||||
react-dom: 19.0.0(react@19.0.0)
|
react-dom: 19.0.0(react@19.0.0)
|
||||||
react-router: 7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
react-router: 7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||||
|
|
||||||
react-router-hono-server@2.11.0(@react-router/dev@7.4.0(@types/node@22.10.7)(jiti@1.21.7)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(terser@5.39.0)(tsx@4.19.2)(typescript@5.8.2)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0))(yaml@2.7.0))(@types/react@19.0.2)(bufferutil@4.0.9)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(utf-8-validate@5.0.10)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0)):
|
react-router-hono-server@2.11.0(patch_hash=3e40672a2de5e41f1467bc15484f757a23322b7df7b9a8b257ab7133e23f95b4)(@react-router/dev@7.4.0(@types/node@22.10.7)(jiti@1.21.7)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(terser@5.39.0)(tsx@4.19.2)(typescript@5.8.2)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0))(yaml@2.7.0))(@types/react@19.0.2)(bufferutil@4.0.9)(react-router@7.4.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(utf-8-validate@5.0.10)(vite@6.2.2(@types/node@22.10.7)(jiti@1.21.7)(terser@5.39.0)(tsx@4.19.2)(yaml@2.7.0)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@drizzle-team/brocli': 0.11.0
|
'@drizzle-team/brocli': 0.11.0
|
||||||
'@hono/node-server': 1.14.0(hono@4.7.5)
|
'@hono/node-server': 1.14.0(hono@4.7.5)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user