]> zoso.dev Git - nano-pow.git/commitdiff
Avoid altering client request payload, and increase MAX_BODY_SIZE to compensate.
authorChris Duncan <chris@zoso.dev>
Sun, 20 Apr 2025 22:52:16 +0000 (15:52 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 20 Apr 2025 22:52:16 +0000 (15:52 -0700)
src/bin/server.ts

index 45f7093b34c890be4fd4ec8eb57b2de587ef95f6..bf3f5a9bfe57f9ee6c9f0c4990da67a2c01e2f94 100755 (executable)
@@ -33,7 +33,7 @@ process.title = 'NanoPow Server'
 const MAX_REQUEST_COUNT = 10
 const MAX_REQUEST_TIME = 60000
 const MAX_REQUEST_SIZE = 1024
-const MAX_BODY_SIZE = 158
+const MAX_BODY_SIZE = 256
 
 const requests: Map<string, { tokens: number, time: number }> = new Map()
 
@@ -88,7 +88,7 @@ async function respond (res: http.ServerResponse, data: Buffer[]): Promise<void>
        let headers: http.OutgoingHttpHeaders = { 'Content-Type': 'application/json' }
        let response: string = 'request failed'
        try {
-               const datastring = Buffer.concat(data).toString().replace(/\s+/g, '')
+               const datastring = Buffer.concat(data).toString()
                if (Buffer.byteLength(datastring) > MAX_BODY_SIZE) {
                        throw new Error('Invalid data.')
                }