ldrouter 1.11.8 → 1.11.12

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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/) and the project adheres to
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [1.11.9] - 2026-09-04
8
+
9
+ ### Fixed
10
+
11
+ - **API routes now return proper JSON errors**: fixed `setNotFoundHandler` logic to ensure `/v1/*` routes always return JSON error responses instead of falling through to HTML SPA index. Route order confirmed: health → admin/gateway → static files.
12
+
7
13
  ## [1.11.8] - 2026-09-03
8
14
 
9
15
  ### Fixed
@@ -94,12 +94,19 @@ export async function buildApp(opts = {}) {
94
94
  await app.register(staticPlugin, { root: webDist, prefix: '/', decorateReply: false });
95
95
  }
96
96
  app.setNotFoundHandler((req, reply) => {
97
- if (req.url.startsWith('/api') || req.url.startsWith('/v1') || req.url.startsWith('/health') || req.url.startsWith('/ready') || req.url.startsWith('/metrics') || !hasWeb) {
97
+ if (req.url.startsWith('/api') || req.url.startsWith('/v1') || req.url.startsWith('/health') || req.url.startsWith('/ready') || req.url.startsWith('/metrics')) {
98
98
  const e = new GatewayError('invalid_request_error', 'Route not found', { status: 404 });
99
99
  reply.code(404).send(toOpenAIError(e, req.id));
100
100
  return;
101
101
  }
102
- reply.type('text/html').send(fs.readFileSync(path.join(webDist, 'index.html')));
102
+ // Serve SPA index.html only for non-API paths when web is available
103
+ if (hasWeb) {
104
+ reply.type('text/html').send(fs.readFileSync(path.join(webDist, 'index.html')));
105
+ return;
106
+ }
107
+ // No web assets - return error for all remaining paths
108
+ const err = new GatewayError('invalid_request_error', 'Not found', { status: 404 });
109
+ reply.code(404).send(toOpenAIError(err, req.id));
103
110
  });
104
111
  // On startup: ensure settings row + detect master key status
105
112
  app.addHook('onReady', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldrouter",
3
- "version": "1.11.8",
3
+ "version": "1.11.12",
4
4
  "description": "LateDev Router — lightweight self-hosted LLM gateway with admin UI",
5
5
  "type": "module",
6
6
  "license": "MIT",