remotion-dev/remotion · error · TypeError

staticFile() does not support absolute paths - got "${path}"

Error message

staticFile() does not support absolute paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths

What it means

staticFile() resolves paths inside the public/ folder, so absolute filesystem paths are rejected. The check looks for common absolute prefixes (/Users, /home, /tmp, /etc, /opt, /var, and Windows drive letters C:, D:, E:). Absolute paths would leak the build machine's filesystem into the bundle and would not exist on the render worker.

Source

Thrown at packages/core/src/static-file.ts:123

	if (path.startsWith('..') || path.startsWith('./')) {
		throw new TypeError(
			`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`,
		);
	}

	if (
		path.startsWith('/Users') ||
		path.startsWith('/home') ||
		path.startsWith('/tmp') ||
		path.startsWith('/etc') ||
		path.startsWith('/opt') ||
		path.startsWith('/var') ||
		path.startsWith('C:') ||
		path.startsWith('D:') ||
		path.startsWith('E:')
	) {
		throw new TypeError(
			`staticFile() does not support absolute paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`,
		);
	}

	if (path.startsWith('public/')) {
		throw new TypeError(
			`Do not include the public/ prefix when using staticFile() - got "${path}". See: https://remotion.dev/docs/staticfile-relative-paths`,
		);
	}

	const includesHex = includesHexOfUnsafeChar(path);
	if (includesHex.containsHex) {
		warnOnce(
			`WARNING: You seem to pass an already encoded path (path contains ${includesHex.hexCode}). Since Remotion 4.0, the encoding is done by staticFile() itself. You may want to remove a encodeURIComponent() wrapping.`,
		);
	}

	if (typeof window !== 'undefined') {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Move the asset into public/ and reference it by name only, e.g. `staticFile('foo.png')`.
  2. If you must read server-side files, copy them to public/ at build time instead of passing absolute paths.
  3. Strip the absolute prefix and ensure the file lives under public/.

Example fix

// before
const src = staticFile('/Users/me/assets/logo.png');

// after (move /Users/me/assets/logo.png to <project>/public/logo.png)
const src = staticFile('logo.png');
Defensive patterns

Strategy: validation

Validate before calling

const ABSOLUTE_PREFIXES = ['/Users','/home','/tmp','/etc','/opt','/var','C:','D:','E:'];
const isAbsoluteFsPath = (p: string) =>
  ABSOLUTE_PREFIXES.some((pre) => p.startsWith(pre));

const resolveAsset = (p: string) => {
  if (isAbsoluteFsPath(p)) {
    throw new Error(`copy ${p} into public/ and pass the basename`);
  }
  return staticFile(p);
};

Type guard

const isPublicAssetName = (p: string) =>
  typeof p === 'string' &&
  !p.startsWith('/') &&
  !/^[A-Z]:/.test(p) &&
  !p.startsWith('public/');

Prevention

When it happens

Trigger: Calling `staticFile('/Users/me/project/foo.png')`, `staticFile('/tmp/render.mp4')`, or `staticFile('C:\\dev\\video.mp4')`, often by passing a path from a Node script or a file picker.

Common situations: Copy-pasting an absolute path from the OS; feeding paths produced by `path.join(__dirname, ...)` or `fs` operations into staticFile(); mixing Node-side asset handling with the Remotion runtime.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/3623fe9d1a3346de. Report an issue: GitHub.