diff --git a/contributors.yml b/contributors.yml index 206e7850b98..594936a0592 100644 --- a/contributors.yml +++ b/contributors.yml @@ -332,6 +332,7 @@ - therealflyingcoder - thomasheyenbrock - thomasrettig +- TillaTheHun0 - tjefferson08 - tombyrer - toyozaki diff --git a/packages/remix-serve/index.ts b/packages/remix-serve/index.ts index 2072474695a..5b54be58b54 100644 --- a/packages/remix-serve/index.ts +++ b/packages/remix-serve/index.ts @@ -2,8 +2,13 @@ import express from "express"; import compression from "compression"; import morgan from "morgan"; import { createRequestHandler } from "@remix-run/express"; +import type { GetLoadContextFunction } from "@remix-run/express"; -export function createApp(buildPath: string, mode = "production") { +export function createApp( + buildPath: string, + mode = "production", + getLoadContext?: GetLoadContextFunction +) { let app = express(); app.disable("x-powered-by"); @@ -21,11 +26,19 @@ export function createApp(buildPath: string, mode = "production") { app.all( "*", mode === "production" - ? createRequestHandler({ build: require(buildPath), mode }) + ? createRequestHandler({ + build: require(buildPath), + mode, + getLoadContext, + }) : (req, res, next) => { // require cache is purged in @remix-run/dev where the file watcher is let build = require(buildPath); - return createRequestHandler({ build, mode })(req, res, next); + return createRequestHandler({ build, mode, getLoadContext })( + req, + res, + next + ); } );