Skip to content

Commit 7e2e6ef

Browse files
fix(database-ui): use byte length for content length header
1 parent d90925d commit 7e2e6ef

File tree

1 file changed

+4
-3
lines changed
  • packages/cli/src/projects/db-studio/api

1 file changed

+4
-3
lines changed

packages/cli/src/projects/db-studio/api/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,19 @@ const server = createServer(options, (req, res) => {
4646
// Handle the API request
4747
const response = await handleApiRequest(url, method, body, databases, Database);
4848

49-
// Write response with Content-Length
49+
// Write response with Content-Length (byte length, not character length)
5050
res.writeHead(response.status, {
5151
...response.headers,
52-
'Content-Length': response.body.length
52+
'Content-Length': Buffer.byteLength(response.body, 'utf8')
5353
});
54+
console.log(response.body);
5455
res.end(response.body);
5556
} catch (err) {
5657
console.error("Error handling request:", err);
5758
const errorBody = JSON.stringify({ error: 'Internal server error' });
5859
res.writeHead(500, {
5960
'Content-Type': 'application/json',
60-
'Content-Length': errorBody.length
61+
'Content-Length': Buffer.byteLength(errorBody, 'utf8')
6162
});
6263
res.end(errorBody);
6364
}

0 commit comments

Comments
 (0)