Skip to content

🎥 Make videos programmatically with React

check if path passed to SSR API is a valid webpack bundle directory

Jonny Burgercd78de15f5f2
diff --git a/packages/renderer/src/prepare-server.ts b/packages/renderer/src/prepare-server.ts
index 1fc0e0b071..478030e086 100644
--- a/packages/renderer/src/prepare-server.ts
+++ b/packages/renderer/src/prepare-server.ts
@@ -1,3 +1,5 @@
+import {existsSync} from 'fs';
+import path from 'path';
import {FfmpegExecutable} from 'remotion';
import {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';
import {isServeUrl} from './is-serve-url';
@@ -41,6 +43,15 @@ export const prepareServer = async ({
});
}
+ // Check if the path has a `index.html` file
+ const indexFile = path.join(webpackConfigOrServeUrl, 'index.html');
+ const exists = existsSync(indexFile);
+ if (!exists) {
+ throw new Error(
+ `Tried to serve the Webpack bundle on a HTTP server, but the file ${indexFile} does not exist. Is this a valid path to a Webpack bundle?`
+ );
+ }
+
const {port: serverPort, close} = await serveStatic(webpackConfigOrServeUrl, {
downloadDir,
onDownload,