@lark-apaas/fullstack-rspack-preset 1.0.23 → 1.0.25-alpha.0

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/lib/preset.js CHANGED
@@ -14,6 +14,15 @@ const slardar_performance_monitor_plugin_1 = __importDefault(require("./rspack-p
14
14
  const view_context_injection_plugin_1 = __importDefault(require("./rspack-plugins/view-context-injection-plugin"));
15
15
  const og_meta_injection_plugin_1 = __importDefault(require("./rspack-plugins/og-meta-injection-plugin"));
16
16
  const dev_server_snapdom_proxy_1 = require("./utils/dev-server-snapdom-proxy");
17
+ function sendBackendUnavailable502(_err, _req, res) {
18
+ if (res.headersSent)
19
+ return;
20
+ res.writeHead(502, {
21
+ 'Content-Type': 'application/json; charset=utf-8',
22
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
23
+ });
24
+ res.end(JSON.stringify({ error: 'Bad Gateway', message: 'Backend service is not running' }));
25
+ }
17
26
  function createRecommendRspackConfig(options) {
18
27
  const { isDev = true, enableReactRefresh = isDev, needRoutes = true, clientBasePath = '', publicPath = '', // 静态资源路径
19
28
  } = options;
@@ -283,11 +292,13 @@ function createRecommendRspackConfig(options) {
283
292
  context: [`${clientBasePath}/api`],
284
293
  target: `http://localhost:${serverPort}`,
285
294
  changeOrigin: true,
295
+ onError: sendBackendUnavailable502,
286
296
  },
287
297
  {
288
298
  context: [`${clientBasePath}/__innerapi__`],
289
299
  target: `http://localhost:${serverPort}`,
290
300
  changeOrigin: true,
301
+ onError: sendBackendUnavailable502,
291
302
  },
292
303
  {
293
304
  context: (pathname, req) => {
@@ -72,7 +72,7 @@ function getViewContextScriptContent() {
72
72
  window.appId = "{{appId}}";
73
73
  const appInfo = {
74
74
  name: "{{appName}}",
75
- avatar: "{{appAvatar}}",
75
+ avatar: "{{{appAvatar}}}",
76
76
  description: "{{appDescription}}",
77
77
  };
78
78
  if (appInfo.name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.23",
3
+ "version": "1.0.25-alpha.0",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",