@lark-apaas/fullstack-rspack-preset 1.0.13-alpha.proxy.2 → 1.0.13-alpha.proxy.7

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.
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.registerSnapDomProxyMiddleware = registerSnapDomProxyMiddleware;
8
8
  const path_1 = __importDefault(require("path"));
9
9
  function registerSnapDomProxyMiddleware(serverApp, options = {}) {
10
- const { proxyUrl = '/snapdom-proxy', baseUrl = '/' } = options;
10
+ // `/dev`前缀保证请求不会被拦截
11
+ const { proxyUrl = '/dev/snapdom-proxy', baseUrl = '/' } = options;
11
12
  const targetUrl = path_1.default.join(baseUrl, proxyUrl);
12
13
  // req: import('express').Request
13
14
  // res: import('express').Response
@@ -30,13 +31,11 @@ function registerSnapDomProxyMiddleware(serverApp, options = {}) {
30
31
  catch {
31
32
  targetUrl = decodeURIComponent(targetUrl);
32
33
  }
33
- // 发起请求(无需特殊的跨域配置)
34
34
  const response = await fetch(targetUrl);
35
35
  const contentType = response.headers.get('content-type');
36
36
  if (contentType) {
37
37
  res.setHeader('Content-Type', contentType);
38
38
  }
39
- // 返回内容
40
39
  const buffer = await response.arrayBuffer();
41
40
  res.send(Buffer.from(buffer));
42
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.13-alpha.proxy.2",
3
+ "version": "1.0.13-alpha.proxy.7",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",