@quicktvui/web-cli 2.3.0 → 2.4.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/DevServer.js
CHANGED
|
@@ -369,7 +369,13 @@ class DevServer {
|
|
|
369
369
|
|
|
370
370
|
// dist/dev/ 下的文件 - 映射到项目的 dist/dev 目录
|
|
371
371
|
if (pathname.startsWith('/dist/dev/')) {
|
|
372
|
-
|
|
372
|
+
let relativePath = pathname.replace('/dist/dev/', '')
|
|
373
|
+
// 剥离 bundles-dev 中间段:web-runtime 的 publicPath 包含 bundles-dev,
|
|
374
|
+
// 导致 webpack 管理的资源(如图片)URL 会变成 /dist/dev/bundles-dev/assets/xxx.png
|
|
375
|
+
// 但实际文件在 dist/dev/assets/xxx.png,bundles-dev 只是 Hippy debug server 的路径约定
|
|
376
|
+
if (relativePath.startsWith('bundles-dev/')) {
|
|
377
|
+
relativePath = relativePath.replace('bundles-dev/', '')
|
|
378
|
+
}
|
|
373
379
|
const filePath = path.join(this.distDir, relativePath)
|
|
374
380
|
this._serveStaticFile(res, filePath, this.distDir)
|
|
375
381
|
return
|
|
@@ -566,11 +572,22 @@ class DevServer {
|
|
|
566
572
|
})
|
|
567
573
|
|
|
568
574
|
proxyReq.on('error', (err) => {
|
|
569
|
-
console.error(
|
|
575
|
+
console.error(
|
|
576
|
+
`[Proxy] Error: ${err.message} -> ${protocol}://${hostname}:${port}${proxyPath}`
|
|
577
|
+
)
|
|
570
578
|
if (!res.headersSent) {
|
|
571
|
-
res.writeHead(502, {
|
|
579
|
+
res.writeHead(502, {
|
|
580
|
+
'Content-Type': 'application/json',
|
|
581
|
+
'Access-Control-Allow-Origin': this.corsOrigin,
|
|
582
|
+
})
|
|
572
583
|
}
|
|
573
|
-
res.end(
|
|
584
|
+
res.end(
|
|
585
|
+
JSON.stringify({
|
|
586
|
+
error: 'Proxy error',
|
|
587
|
+
message: err.message,
|
|
588
|
+
target: `${protocol}://${hostname}:${port}${proxyPath}`,
|
|
589
|
+
})
|
|
590
|
+
)
|
|
574
591
|
})
|
|
575
592
|
|
|
576
593
|
// 转发请求体(POST/PUT 等)
|