11import { join } from 'node:path' ;
2- import { versions } from 'node:process' ;
2+ import { exit , versions } from 'node:process' ;
33import { createHonoServer } from 'react-router-hono-server/node' ;
44import log from '~/utils/log' ;
55import { loadIntegration } from './config/integration' ;
@@ -19,7 +19,17 @@ declare global {
1919// This module contains a side-effect because everything running here
2020// exists for the lifetime of the process, making it appropriate.
2121log . info ( 'server' , 'Running Node.js %s' , versions . node ) ;
22- const config = await loadConfig ( ) ;
22+ let config : HeadplaneConfig ;
23+
24+ try {
25+ config = await loadConfig ( ) ;
26+ } catch ( error ) {
27+ if ( error instanceof ConfigError ) {
28+ log . error ( 'server' , 'Unable to load configuration: %s' , error . message ) ;
29+ }
30+
31+ exit ( 1 ) ;
32+ }
2333
2434const db = await createDbClient ( join ( config . server . data_path , 'hp_persist.db' ) ) ;
2535const agents = await createHeadplaneAgent (
@@ -39,6 +49,8 @@ const hsApi = await createHeadscaleInterface(
3949export type LoadContext = typeof appLoadContext ;
4050
4151import 'react-router' ;
52+ import { HeadplaneConfig } from './config/config-schema' ;
53+ import { ConfigError } from './config/error' ;
4254import { createOidcConnector } from './web/oidc-connector' ;
4355
4456declare module 'react-router' {
@@ -92,6 +104,11 @@ export default createHonoServer({
92104 } ) ;
93105 } ,
94106 serveStaticOptions : {
107+ publicAssets : {
108+ // This is part of our monkey-patch for react-router-hono-server
109+ // To see the first part, go to the patches/ directory.
110+ rewriteRequestPath : ( path ) => path . replace ( `${ __PREFIX__ } ` , '' ) ,
111+ } ,
95112 clientAssets : {
96113 // This is part of our monkey-patch for react-router-hono-server
97114 // To see the first part, go to the patches/ directory.
0 commit comments