Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main <- develop #159

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion frontend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import sirv from "sirv";
import cookieParser from "cookie-parser";
import path from "node:path";
import {fileURLToPath} from "node:url";
import * as nodePath from "node:path";
import * as nodeUrl from "node:url";

installGlobals();

Expand Down Expand Up @@ -70,7 +72,7 @@ app.use("*", async (req, res) => {
render = (await vite.ssrLoadModule("/src/entry.server.tsx")).render;
} else {
template = templateHtml;
render = (await import(path.join(__dirname, "./dist/server/entry.server.js"))).render;
render = (await dynamicImport(path.join(__dirname, "./dist/server/entry.server.js"))).render;
}

const {appHtml, dehydratedState, helmetContext} = await render(
Expand Down Expand Up @@ -110,3 +112,10 @@ app.use("*", async (req, res) => {
app.listen(port, () => {
console.info(`SSR Serving at http://localhost:${port}`);
});

const dynamicImport = async (path) => {
return import(
nodePath.isAbsolute(path) ? nodeUrl.pathToFileURL(path).toString() : path
);

}
Loading