@lark-apaas/fullstack-rspack-preset 1.0.57-alpha.2 → 1.0.57-beta.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 +19 -0
- package/package.json +1 -1
package/lib/preset.js
CHANGED
|
@@ -484,6 +484,25 @@ function createRecommendRspackConfig(options) {
|
|
|
484
484
|
},
|
|
485
485
|
target: `http://localhost:${serverPort}`,
|
|
486
486
|
changeOrigin: true,
|
|
487
|
+
// 跟 /api proxy 同款,HTML 转发也补 larkgw 注入的 header(webuser + csrf),否则 NestJS
|
|
488
|
+
// ViewContextMiddleware 拿不到 appId,window.appId 渲染为空 → 前端拼 /app/null/... 全 404。
|
|
489
|
+
...(localDev && localDevWebUserHeader
|
|
490
|
+
? { headers: { 'x-larkgw-suda-webuser': localDevWebUserHeader } }
|
|
491
|
+
: {}),
|
|
492
|
+
...(localDev
|
|
493
|
+
? {
|
|
494
|
+
onProxyReq: (proxyReq, req) => {
|
|
495
|
+
if (proxyReq.getHeader('x-suda-csrf-token'))
|
|
496
|
+
return;
|
|
497
|
+
const cookie = req.headers.cookie;
|
|
498
|
+
if (!cookie)
|
|
499
|
+
return;
|
|
500
|
+
const m = /(?:^|;\s*)suda-csrf-token=([^;]+)/.exec(cookie);
|
|
501
|
+
if (m)
|
|
502
|
+
proxyReq.setHeader('x-suda-csrf-token', m[1]);
|
|
503
|
+
},
|
|
504
|
+
}
|
|
505
|
+
: {}),
|
|
487
506
|
logLevel: 'debug',
|
|
488
507
|
onError: (err, req, res) => (0, devtool_kits_1.handleDevProxyError)(err, req, res, {
|
|
489
508
|
target: `http://localhost:${serverPort}`,
|