fix: (regression 0.30.1) upload not working https://github.com/rejetto/hfs/issues/100
Massimo Melina committed
Feb 13, 2023 at 10:42 UTC
fc291aeeefecd01c84ce5de5336e7bae8c9f6345
1 file changed
+3
-2
src/middlewares.ts
+3
-2
@@ -8,7 +8,7 @@ import {
8
BUILD_TIMESTAMP,
9
DEV,
10
SESSION_DURATION,
11
- HTTP_FORBIDDEN, HTTP_NOT_FOUND, HTTP_FOOL,
11
+ HTTP_FORBIDDEN, HTTP_NOT_FOUND, HTTP_FOOL, API_URI,
12
} from './const'
13
import { FRONTEND_URI } from './const'
14
import { cantReadStatusCode, hasPermission, nodeIsDirectory, urlToNode, vfs } from './vfs'
@@ -199,7 +199,8 @@ async function srpCheck(username: string, password: string) {
199
200
// unify get/post parameters, with JSON decoding to not be limited to strings
201
export const paramsDecoder: Koa.Middleware = async (ctx, next) => {
202
- ctx.params = ctx.method === 'POST' ? tryJson(await stream2string(ctx.req))
202
+ ctx.params = ctx.method === 'POST' && ctx.originalUrl.startsWith(API_URI)
203
+ ? tryJson(await stream2string(ctx.req))
204
: objSameKeys(ctx.query, x => Array.isArray(x) ? x : tryJson(x))
205
await next()
206
}