@rpcbase/server 0.449.0 → 0.450.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/dist/index.js +5 -21
- package/dist/ssrMiddleware.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -517,6 +517,8 @@ async function renderSSR(req, dataRoutes) {
|
|
|
517
517
|
const ABORT_DELAY_MS = 1e4;
|
|
518
518
|
const APP_HTML_PLACEHOLDER = "<!--app-html-->";
|
|
519
519
|
const DEFAULT_SERVER_ERROR_MESSAGE = "We couldn't render this page on the server. Please refresh and try again.";
|
|
520
|
+
const FALLBACK_ERROR_TEMPLATE_START = `<!doctype html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width,initial-scale=1" /><title>Server error</title><style>body{margin:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:#0b1021;color:#eef1f7;display:flex;align-items:center;justify-content:center;min-height:100vh;}main{max-width:420px;padding:32px;background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.08);border-radius:14px;box-shadow:0 25px 50px rgba(0,0,0,0.35);}h1{font-size:24px;margin:0 0 8px;}p{margin:0 0 12px;line-height:1.5;}code{background:rgba(255,255,255,0.08);padding:2px 6px;border-radius:6px;font-size:12px;}</style></head><body><main>`;
|
|
521
|
+
const FALLBACK_ERROR_TEMPLATE_END = "</main></body></html>";
|
|
520
522
|
const isProduction = env.NODE_ENV === "production";
|
|
521
523
|
const templateHtml = isProduction ? readFileSync("./build/dist/client/src/client/index.html", "utf-8") : "";
|
|
522
524
|
const formatErrorDetails = (error) => {
|
|
@@ -534,22 +536,6 @@ const formatErrorDetails = (error) => {
|
|
|
534
536
|
return void 0;
|
|
535
537
|
}
|
|
536
538
|
};
|
|
537
|
-
const formatPlainErrorBody = (error) => {
|
|
538
|
-
if (isProduction) {
|
|
539
|
-
return "Server error";
|
|
540
|
-
}
|
|
541
|
-
if (error instanceof Error) {
|
|
542
|
-
return error.stack || error.message;
|
|
543
|
-
}
|
|
544
|
-
if (typeof error === "string") {
|
|
545
|
-
return error;
|
|
546
|
-
}
|
|
547
|
-
try {
|
|
548
|
-
return JSON.stringify(error, null, 2);
|
|
549
|
-
} catch {
|
|
550
|
-
return "Unknown error";
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
539
|
const sendErrorResponse = ({
|
|
554
540
|
res,
|
|
555
541
|
htmlStart,
|
|
@@ -561,10 +547,8 @@ const sendErrorResponse = ({
|
|
|
561
547
|
errorExtraComponent
|
|
562
548
|
}) => {
|
|
563
549
|
if (res.headersSent) return;
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
550
|
+
const start = htmlStart ?? FALLBACK_ERROR_TEMPLATE_START;
|
|
551
|
+
const end = htmlEnd ?? FALLBACK_ERROR_TEMPLATE_END;
|
|
568
552
|
res.status(status);
|
|
569
553
|
res.set({ "Content-Type": "text/html" });
|
|
570
554
|
const details = formatErrorDetails(error);
|
|
@@ -588,7 +572,7 @@ const sendErrorResponse = ({
|
|
|
588
572
|
...state,
|
|
589
573
|
details: isProduction ? void 0 : details
|
|
590
574
|
})};<\/script>`;
|
|
591
|
-
res.end(`${
|
|
575
|
+
res.end(`${start}${markup}${serializedState}${end}`);
|
|
592
576
|
};
|
|
593
577
|
const ssrMiddleware = ({
|
|
594
578
|
viteInstance,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssrMiddleware.d.ts","sourceRoot":"","sources":["../src/ssrMiddleware.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACjI,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,YAAY,EAAE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