remotion-dev/remotion · error · Error

The value "${path}" is already prefixed with the static base

Error message

The value "${path}" is already prefixed with the static base ${window.remotion_staticBase}. You don't need to call staticFile() on it.

What it means

staticFile() prefixes a path with Remotion's runtime static base (`window.remotion_staticBase`). This guard fires when the path already starts with that base, meaning staticFile() was effectively called twice on the same value. Double-prefixing would produce an invalid URL like `/staticbase/staticbase/foo`.

Source

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

			return {containsHex: true, hexCode: key as HexCode};
		}
	}

	return {containsHex: false};
};

const trimLeadingSlash = (path: string): string => {
	if (path.startsWith('/')) {
		return trimLeadingSlash(path.substring(1));
	}

	return path;
};

const inner = (path: string): string => {
	if (typeof window !== 'undefined' && window.remotion_staticBase) {
		if (path.startsWith(window.remotion_staticBase)) {
			throw new Error(
				`The value "${path}" is already prefixed with the static base ${window.remotion_staticBase}. You don't need to call staticFile() on it.`,
			);
		}

		return `${window.remotion_staticBase}/${trimLeadingSlash(path)}`;
	}

	return `/${trimLeadingSlash(path)}`;
};

const encodeBySplitting = (path: string): string => {
	const splitBySlash = path.split('/');

	const encodedArray = splitBySlash.map((element) => {
		return encodeURIComponent(element);
	});
	const merged = encodedArray.join('/');
	return merged;

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Call staticFile() exactly once per asset and reuse the returned string.
  2. If you stored `const url = staticFile('foo')`, pass `url` directly to <Audio>/<Img>/etc., not back into staticFile().
  3. Search the codebase for nested staticFile() calls and unwrap the inner one.

Example fix

// before
const a = staticFile('foo.png');
const b = staticFile(a);

// after
const a = staticFile('foo.png');
const b = a;
Defensive patterns

Strategy: validation

Validate before calling

const resolveAsset = (input: string) =>
  input.startsWith(window.remotion_staticBase ?? '/staticbase')
    ? input
    : staticFile(input);

Type guard

const isAlreadyPrefixed = (p: string) =>
  typeof window !== 'undefined' &&
  !!window.remotion_staticBase &&
  p.startsWith(window.remotion_staticBase);

Prevention

When it happens

Trigger: Calling `staticFile(staticFile('foo'))`, storing the result of staticFile() and passing it back into staticFile(), or manually prepending the static base before calling staticFile().

Common situations: Precomputing a URL once and accidentally wrapping it again in a helper that also calls staticFile(); refactoring a chain of file path transformations; bundling assets whose URLs were already resolved by the Studio.

Related errors


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