🎥 Make videos programmatically with React
`@remotion/renderer`: Check if IPv6 is supported before binding
Jonny Burger82e13e8a01bf
diff --git a/packages/cli/src/preview-server/start-server.ts b/packages/cli/src/preview-server/start-server.tsindex a131662eff..5fabf946ba 100644--- a/packages/cli/src/preview-server/start-server.ts+++ b/packages/cli/src/preview-server/start-server.ts@@ -110,8 +110,10 @@ export const startServer = async (options: {const maxTries = 5;- // Default Node.js host, but explicity- const host = '::';+ const host = RenderInternals.isIpV6Supported() ? '::' : '0.0.0.0';+ const hostsToTry = RenderInternals.isIpV6Supported()+ ? ['::', '::1']+ : ['0.0.0.0', '127.0.0.1'];for (let i = 0; i < maxTries; i++) {try {@@ -120,7 +122,7 @@ export const startServer = async (options: {desiredPort,from: 3000,to: 3100,- hostsToTry: ['::1', '::'],+ hostsToTry,}).then(({port, didUsePort}) => {server.listen({diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.tsindex aad81f5251..6f047f01c4 100644--- a/packages/renderer/src/index.ts+++ b/packages/renderer/src/index.ts@@ -45,6 +45,7 @@ import {validVideoImageFormats,} from './image-format';import {isAudioCodec} from './is-audio-codec';+import {isIpV6Supported} from './is-ipv6-supported';import {isServeUrl} from './is-serve-url';import {DEFAULT_JPEG_QUALITY, validateJpegQuality} from './jpeg-quality';import {isEqualOrBelowLogLevel, isValidLogLevel, logLevels} from './log-level';@@ -215,6 +216,7 @@ export const RenderInternals = {internalRenderMedia,validOpenGlRenderers,copyImageToClipboard,+ isIpV6Supported,};// Warn of potential performance issues with Apple Silicon (M1 chip under Rosetta)diff --git a/packages/renderer/src/is-ipv6-supported.ts b/packages/renderer/src/is-ipv6-supported.tsnew file mode 100644index 0000000000..63f81e48a5--- /dev/null+++ b/packages/renderer/src/is-ipv6-supported.ts@@ -0,0 +1,17 @@+import os from 'os';++export const isIpV6Supported = (): boolean => {+ const interfaces = os.networkInterfaces();++ for (const iface in interfaces) {+ for (const configuration of interfaces[+ iface+ ] as os.NetworkInterfaceInfo[]) {+ if (configuration.family === 'IPv6' && !configuration.internal) {+ return true;+ }+ }+ }++ return false;+};diff --git a/packages/renderer/src/serve-static.ts b/packages/renderer/src/serve-static.tsindex 4f8cfcdf28..a6385ebfb4 100644--- a/packages/renderer/src/serve-static.ts+++ b/packages/renderer/src/serve-static.ts@@ -3,6 +3,7 @@ import http from 'node:http';import type {DownloadMap} from './assets/download-map';import type {Compositor} from './compositor/compositor';import {getDesiredPort} from './get-port';+import {isIpV6Supported} from './is-ipv6-supported';import type {LogLevel} from './log-level';import {startOffthreadVideoServer} from './offthread-video-server';import {serveHandler} from './serve-handler';@@ -71,8 +72,11 @@ export const serveStatic = async (const maxTries = 5;- // Default Node.js host, but explicity- const host = '::';+ const host = isIpV6Supported() ? '::' : '0.0.0.0';+ const hostsToTry = isIpV6Supported()+ ? ['::', '::1']+ : ['0.0.0.0', '127.0.0.1'];+for (let i = 0; i < maxTries; i++) {try {selectedPort = await new Promise<number>((resolve, reject) => {@@ -80,7 +84,7 @@ export const serveStatic = async (desiredPort: options?.port ?? undefined,from: 3000,to: 3100,- hostsToTry: ['::', '::1'],+ hostsToTry,}).then(({port, didUsePort}) => {server.listen({port, host});