@niledatabase/server 3.0.0-alpha.44 → 3.0.0-alpha.45
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/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -516,10 +516,17 @@ async function request(url, _init, config) {
|
|
|
516
516
|
updatedHeaders.set("niledb-origin", requestUrl.origin);
|
|
517
517
|
const params = { ...init, headers: updatedHeaders };
|
|
518
518
|
if (params.method === "POST" || params.method === "PUT") {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
519
|
+
try {
|
|
520
|
+
updatedHeaders.set("content-type", "application/json");
|
|
521
|
+
const initBody = await new Response(_init.request.clone().body).json();
|
|
522
|
+
const requestBody = await new Response(request2.clone().body).json();
|
|
523
|
+
params.body = JSON.stringify(initBody ?? requestBody);
|
|
524
|
+
} catch (e) {
|
|
525
|
+
updatedHeaders.set("content-type", "application/x-www-form-urlencoded");
|
|
526
|
+
const initBody = await new Response(_init.request.clone().body).text();
|
|
527
|
+
const requestBody = await new Response(request2.clone().body).text();
|
|
528
|
+
params.body = initBody ?? requestBody;
|
|
529
|
+
}
|
|
523
530
|
}
|
|
524
531
|
try {
|
|
525
532
|
const res = await fetch(url, { ...params }).catch((e) => {
|
|
@@ -1322,9 +1329,6 @@ async function route5(req, config) {
|
|
|
1322
1329
|
headers: req.headers
|
|
1323
1330
|
};
|
|
1324
1331
|
if (req.method === "POST") {
|
|
1325
|
-
if (typeof req.clone === "function") {
|
|
1326
|
-
init.body = req.clone().body;
|
|
1327
|
-
}
|
|
1328
1332
|
const [provider] = new URL(req.url).pathname.split("/").reverse();
|
|
1329
1333
|
url = `${proxyRoutes(config)[key5]}/${provider}`;
|
|
1330
1334
|
}
|