avoid using 404 for missing api, as it is also used by apis
Massimo Melina committed
Mar 2, 2025 at 10:10 UTC
cd1dee93e5be6b62abebc8309c49a5fe776c9e90
1 file changed
+2
-2
src/apiMiddleware.ts
+2
-2
@@ -4,7 +4,7 @@ import Koa from 'koa'
4
import createSSE from './sse'
5
import { Readable } from 'stream'
6
import { asyncGeneratorToReadable, CFG, Promisable } from './misc'
7
-import { HTTP_BAD_REQUEST, HTTP_FOOL, HTTP_NOT_FOUND, PLUGIN_CUSTOM_REST_PREFIX } from './const'
7
+import { HTTP_BAD_REQUEST, HTTP_FOOL, PLUGIN_CUSTOM_REST_PREFIX } from './const'
8
import { defineConfig } from './config'
9
import { firstPlugin } from './plugins'
10
@@ -37,7 +37,7 @@ export function apiMiddleware(apis: ApiHandlers) : Koa.Middleware {
37
const apiFun = customApiRest && firstPlugin(pl => pl.getData().customRest?.[customApiRest])
38
|| apis.hasOwnProperty(apiName) && apis[apiName]!
39
if (!apiFun)
40
- return send(HTTP_NOT_FOUND, 'invalid api')
40
+ return send(HTTP_BAD_REQUEST, 'invalid api')
41
// we don't rely on SameSite cookie option because it's https-only
42
let res
43
try {