@next-core/brick-container 3.15.3 → 3.15.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/brick-container",
3
- "version": "3.15.3",
3
+ "version": "3.15.5",
4
4
  "description": "Brick Container Server",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/brick-container",
6
6
  "license": "GPL-3.0",
@@ -52,15 +52,15 @@
52
52
  "@next-api-sdk/api-gateway-sdk": "^1.1.0",
53
53
  "@next-api-sdk/micro-app-standalone-sdk": "^1.1.0",
54
54
  "@next-core/build-next-bricks": "^1.20.8",
55
- "@next-core/easyops-runtime": "^0.7.27",
56
- "@next-core/http": "^1.1.11",
57
- "@next-core/i18n": "^1.0.41",
55
+ "@next-core/easyops-runtime": "^0.8.0",
56
+ "@next-core/http": "^1.2.0",
57
+ "@next-core/i18n": "^1.0.42",
58
58
  "@next-core/loader": "^1.5.6",
59
- "@next-core/preview": "^0.4.0",
60
- "@next-core/runtime": "^1.40.0",
59
+ "@next-core/preview": "^0.4.1",
60
+ "@next-core/runtime": "^1.41.0",
61
61
  "@next-core/test-next": "^1.0.17",
62
62
  "@next-core/theme": "^1.5.0",
63
- "@next-core/types": "^1.9.0",
63
+ "@next-core/types": "^1.10.0",
64
64
  "broadcast-channel": "^7.0.0",
65
65
  "copy-webpack-plugin": "^12.0.2",
66
66
  "core-js": "^3.36.1",
@@ -73,5 +73,5 @@
73
73
  "@next-core/runtime": "*",
74
74
  "@next-core/utils": "*"
75
75
  },
76
- "gitHead": "d831c6464ee42dd0a3557360214de93a2b25a860"
76
+ "gitHead": "8255acda4ad909cc07087dd99755325e3f31fb70"
77
77
  }
package/serve/getProxy.js CHANGED
@@ -25,13 +25,38 @@ export default function getProxy(env, getRawIndexHtml) {
25
25
  server,
26
26
  } = env;
27
27
  if (useRemote) {
28
+ const apiProxyOptions = getBasicProxyOptions(env, "api/");
29
+
28
30
  return [
29
31
  {
30
32
  ...getBasicProxyOptions(env, "api/websocket_service/"),
31
33
  ws: true,
32
34
  },
33
35
  {
34
- ...getBasicProxyOptions(env, "api/"),
36
+ ...apiProxyOptions,
37
+ context: (pathname, req) => {
38
+ // DO NOT intercept SSE requests.
39
+ const matched =
40
+ pathname.startsWith(apiProxyOptions.context) &&
41
+ req.headers["accept"] === "text/event-stream";
42
+ return matched;
43
+ },
44
+ onProxyReq(proxyReq, req) {
45
+ // Reset the origin header to the remote server
46
+ if (req.headers["origin"] === `http://${host}:${port}`) {
47
+ proxyReq.setHeader("origin", server);
48
+ }
49
+ },
50
+ },
51
+ {
52
+ ...apiProxyOptions,
53
+ context: (pathname, req) => {
54
+ // Intercept requests other than SSE.
55
+ const matched =
56
+ pathname.startsWith(apiProxyOptions.context) &&
57
+ req.headers["accept"] !== "text/event-stream";
58
+ return matched;
59
+ },
35
60
  selfHandleResponse: true,
36
61
  bypass(req) {
37
62
  const appId = getAppIdFromBootstrapPath(req.path);
package/serve/index.js CHANGED
@@ -25,13 +25,20 @@ const distDir = path.join(__dirname, "../dist");
25
25
  const app = express();
26
26
 
27
27
  if (sizeCheck) {
28
- app.use((req, res, next) => {
28
+ app.use((_req, res, next) => {
29
29
  res.set("Cache-Control", "no-store");
30
30
  next();
31
31
  });
32
32
  }
33
33
 
34
- app.use(compression());
34
+ app.use((req, res, next) => {
35
+ // DO NOT compress SSE responses
36
+ if (req.headers["accept"] === "text/event-stream") {
37
+ next();
38
+ } else {
39
+ compression()(req, res, next);
40
+ }
41
+ });
35
42
 
36
43
  const middlewares = [
37
44
  ...(env.localMocks ?? []),
@@ -56,7 +63,7 @@ if (useLocalContainer) {
56
63
  });
57
64
 
58
65
  // Serve browse-happy.html
59
- app.get(`${baseHref}${browseHappyHtml}`, (req, res) => {
66
+ app.get(`${baseHref}${browseHappyHtml}`, (_req, res) => {
60
67
  res.sendFile(path.join(distDir, browseHappyHtml));
61
68
  });
62
69