crg-dev-kit 2.0.0 → 2.0.1
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/package.json +1 -1
- package/server.js +9 -1
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -563,7 +563,15 @@ function readBody(req, res, cb) {
|
|
|
563
563
|
req.on('end', () => {
|
|
564
564
|
if (res.writableEnded) return;
|
|
565
565
|
try {
|
|
566
|
-
|
|
566
|
+
const ct = (req.headers['content-type'] || '');
|
|
567
|
+
let data;
|
|
568
|
+
if (ct.includes('application/json')) {
|
|
569
|
+
data = JSON.parse(body);
|
|
570
|
+
} else {
|
|
571
|
+
// Parse URL-encoded form data (htmx default)
|
|
572
|
+
data = Object.fromEntries(new URLSearchParams(body));
|
|
573
|
+
}
|
|
574
|
+
cb(data);
|
|
567
575
|
} catch (e) {
|
|
568
576
|
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
569
577
|
res.end(JSON.stringify({ error: e.message }));
|