rasengan 1.0.0-beta.44 → 1.0.0-beta.45
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.
|
@@ -67,7 +67,7 @@ var RenderApp = function (_a) {
|
|
|
67
67
|
} }) }) }));
|
|
68
68
|
};
|
|
69
69
|
export default function renderStream(router_1, context_1) {
|
|
70
|
-
return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res, env) {
|
|
71
71
|
if (helmetContext === void 0) { helmetContext = {}; }
|
|
72
72
|
return __generator(this, function (_a) {
|
|
73
73
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
@@ -76,10 +76,18 @@ export default function renderStream(router_1, context_1) {
|
|
|
76
76
|
var _a = renderToPipeableStream(_jsx(RenderApp, { router: router, context: context, helmetContext: helmetContext, bootstrap: bootstrap, styles: styles }), {
|
|
77
77
|
onShellReady: function () {
|
|
78
78
|
shellRendered = true;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
if (env === "vercel") {
|
|
80
|
+
res
|
|
81
|
+
.status(responseStatusCode)
|
|
82
|
+
.setHeader("Content-Type", "text/html")
|
|
83
|
+
.setHeader("Cache-Control", "max-age=31536000");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
res.status(responseStatusCode).set({
|
|
87
|
+
"Content-Type": "text/html",
|
|
88
|
+
"Cache-Control": "max-age=31536000",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
83
91
|
resolve(res);
|
|
84
92
|
pipe(res);
|
|
85
93
|
},
|
|
@@ -176,7 +176,7 @@ export default function handler(req, res) {
|
|
|
176
176
|
}
|
|
177
177
|
helmetContext = {};
|
|
178
178
|
router = createStaticRouter(handler_1.dataRoutes, context);
|
|
179
|
-
return [4 /*yield*/, render(router, context, helmetContext, bootstrap, styles, res)];
|
|
179
|
+
return [4 /*yield*/, render(router, context, helmetContext, bootstrap, styles, res, "vercel")];
|
|
180
180
|
case 15:
|
|
181
181
|
// If stream mode enabled, render the page as a plain text
|
|
182
182
|
return [2 /*return*/, _a.sent()];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Response } from "express";
|
|
2
2
|
import { type Router } from "@remix-run/router";
|
|
3
3
|
import { StaticHandlerContext } from "react-router-dom/server";
|
|
4
|
-
export default function renderStream(router: Router, context: StaticHandlerContext, helmetContext: any, bootstrap: string, styles: string, res: Response): Promise<unknown>;
|
|
4
|
+
export default function renderStream(router: Router, context: StaticHandlerContext, helmetContext: any, bootstrap: string, styles: string, res: Response, env?: "vercel" | "netlify" | "cloudflare" | "other"): Promise<unknown>;
|