Skip to content

Commit

Permalink
fix: use reloaded build in requests (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored Dec 12, 2023
1 parent 0e0cf21 commit 42e13ad
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ run();
async function run() {
const BUILD_PATH = path.resolve("build/index.js");
const VERSION_PATH = path.resolve("build/version.txt");

const initialBuild = await reimportServer();
const remixHandler =
process.env.NODE_ENV === "development"
? await createDevRequestHandler(initialBuild)
: createRequestHandler({
build: initialBuild,
mode: initialBuild.mode,
});

const app = express();
const metricsApp = express();
Expand Down Expand Up @@ -90,17 +98,7 @@ async function run() {

app.use(morgan("tiny"));

app.all("*", async (...args) => {
const handler =
process.env.NODE_ENV === "development"
? await createDevRequestHandler(initialBuild)
: createRequestHandler({
build: initialBuild,
mode: initialBuild.mode,
});

return handler(...args);
});
app.all("*", remixHandler);

const port = process.env.PORT || 3000;
app.listen(port, () => {
Expand Down

0 comments on commit 42e13ad

Please sign in to comment.