diff --git a/backend/index.js b/backend/index.js index cb7c706..71ff524 100644 --- a/backend/index.js +++ b/backend/index.js @@ -37,7 +37,7 @@ const wrap_transport_sendbytes = function (ws, msg_bytes) { return } -const start_server = function ({ context_meta, config, jsbuild_app_frontend, handle_transport_bytes }) { +const start_server = function ({ context_meta, config, jsbuild_app_frontend, handle_transport_bytes, handle_fetch_fallback }) { const make_session_object = (ws) => { const map_obj = { ws, @@ -130,7 +130,12 @@ const start_server = function ({ context_meta, config, jsbuild_app_frontend, han resp = new Response('Upgrade failed', { status: 500 }) } else { - resp = new Response(null, { status: 404 }) + if (handle_fetch_fallback !== undefined) { + resp = handle_fetch_fallback(req) + } + if (resp === undefined) { + resp = new Response(null, { status: 404 }) + } } return resp }, @@ -225,6 +230,7 @@ const async_run = async function ({ config, jsbuild_app_frontend, handle_transport_bytes, + handle_fetch_fallback, }) { const active_config = { // defaults @@ -239,7 +245,7 @@ const async_run = async function ({ const context_meta = { ws_map: new Map(), } - const server = start_server({ context_meta, config: active_config, jsbuild_app_frontend, handle_transport_bytes }) + const server = start_server({ context_meta, config: active_config, jsbuild_app_frontend, handle_transport_bytes, handle_fetch_fallback }) console.info(`framerock app now running at ${active_config.hostname}:${active_config.port}`) process.on('SIGINT', async () => { console.log('SIGINT intercepted') diff --git a/package.json b/package.json index 117284f..ad29767 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "framerock", - "version": "1.0.0", + "version": "1.0.1", "type": "module", "main": "backend/index.js" }