edgeone 1.2.18-beta.1 → 1.2.19

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.
@@ -184,11 +184,11 @@ function _fetch(
184
184
  ) {
185
185
  const { host } = getUrl(request);
186
186
  const cache = getHostCache(host);
187
- // if (cache && cache.needProxy && cache.expires > Date.now()) {
187
+ if (cache && cache.needProxy && cache.expires > Date.now()) {
188
188
  setHostCache(host);
189
189
  return fetchByProxy(request, requestInit);
190
- // }
191
- // return fetchByOrigin(request, requestInit);
190
+ }
191
+ return fetchByOrigin(request, requestInit);
192
192
  }
193
193
 
194
194
  function getUrl(request) {
@@ -292,12 +292,22 @@ async function fetchByProxy(
292
292
  options.headers.append('oe-host', host);
293
293
  options.headers.append('oe-timestamp', timestamp);
294
294
  options.headers.append('oe-sign', sign);
295
- const originReq = new Request(request);
296
- const req = new Request(originReq.url.replace(host, proxyHost), {
297
- method: originReq.method,
298
- headers: originReq.headers,
299
- body: originReq.body,
295
+
296
+ let clonedRequest;
297
+ if (request instanceof Request && typeof request.clone === 'function') {
298
+ clonedRequest = request.clone();
299
+ } else {
300
+ // If request is not a Request object (e.g., URL string), create a new Request
301
+ clonedRequest = new Request(request);
302
+ }
303
+
304
+ // Create a new request with the proxy host, preserving all properties including body
305
+ const req = new Request(clonedRequest.url.replace(host, proxyHost), {
306
+ method: clonedRequest.method,
307
+ headers: clonedRequest.headers,
308
+ body: clonedRequest.body,
300
309
  });
310
+
301
311
  return __originalFetch(req, options);
302
312
  }
303
313
  // Replace global fetch with _fetch from fetch-proxy
@@ -316,14 +326,14 @@ async function fetchByProxy(
316
326
  ${CC}
317
327
 
318
328
  `}var M$,j$=At(()=>{j3();M$=`
319
- import { createRequire } from 'module';
320
- import { fileURLToPath } from 'url';
329
+ import { createRequire as __createRequire } from 'module';
330
+ import { fileURLToPath as __fileURLToPath } from 'url';
321
331
  import { dirname as __pathDirname } from 'path';
322
332
 
323
333
  // Global variables
324
- const __filename = fileURLToPath(import.meta.url);
334
+ const __filename = __fileURLToPath(import.meta.url);
325
335
  const __dirname = __pathDirname(__filename);
326
- const require = createRequire(import.meta.url);
336
+ const require = __createRequire(import.meta.url);
327
337
 
328
338
  // Global require function
329
339
  globalThis.require = require;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edgeone",
3
- "version": "1.2.18-beta.1",
3
+ "version": "1.2.19",
4
4
  "description": "Command-line interface for TencentCloud Pages Functions",
5
5
  "bin": {
6
6
  "edgeone": "./edgeone-bin/edgeone.js"