{"record":{"id":"9da565d20323213d","repo":"remotion-dev/remotion","slug":"do-not-include-the-public-prefix-when-using-stati","errorCode":null,"errorMessage":"Do not include the public/ prefix when using staticFile() - got \"${path}\". See: https://remotion.dev/docs/staticfile-relative-paths","messagePattern":"Do not include the public/ prefix when using staticFile\\(\\) - got \"(.+?)\"\\. See: https://remotion\\.dev/docs/staticfile-relative-paths","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/static-file.ts","lineNumber":129,"sourceCode":"\n\tif (\n\t\tpath.startsWith('/Users') ||\n\t\tpath.startsWith('/home') ||\n\t\tpath.startsWith('/tmp') ||\n\t\tpath.startsWith('/etc') ||\n\t\tpath.startsWith('/opt') ||\n\t\tpath.startsWith('/var') ||\n\t\tpath.startsWith('C:') ||\n\t\tpath.startsWith('D:') ||\n\t\tpath.startsWith('E:')\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`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`,\n\t\t);\n\t}\n\n\tif (path.startsWith('public/')) {\n\t\tthrow new TypeError(\n\t\t\t`Do not include the public/ prefix when using staticFile() - got \"${path}\". See: https://remotion.dev/docs/staticfile-relative-paths`,\n\t\t);\n\t}\n\n\tconst includesHex = includesHexOfUnsafeChar(path);\n\tif (includesHex.containsHex) {\n\t\twarnOnce(\n\t\t\t`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.`,\n\t\t);\n\t}\n\n\tif (typeof window !== 'undefined') {\n\t\t// This lookup is primarily used by Browser Studio, where virtual assets\n\t\t// have blob: URLs. Regular Studio sources are already encoded using the\n\t\t// same per-path-segment encoding as the fallback below.\n\t\tconst matchingStaticFile = window.remotion_staticFiles?.find(\n\t\t\t(file) => file.name === trimLeadingSlash(path),\n\t\t);","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/static-file.ts#L111-L147","documentation":"staticFile() already resolves paths against the public/ folder, so including the literal `public/` prefix in the argument produces a doubled path (`/public/public/foo`). This guard rejects paths starting with `public/` and asks you to drop the prefix.","triggerScenarios":"Calling `staticFile('public/foo.png')` or `staticFile('public/videos/intro.mp4')`, usually because the developer thinks of the path from the project root.","commonSituations":"Autocompleting from the project root in an editor; copying paths from file explorers that include the public/ folder name; onboarding from frameworks where you do reference the folder explicitly.","solutions":["Drop the `public/` prefix: `staticFile('foo.png')`.","If you build paths programmatically, strip a leading `public/` with `path.replace(/^public\\//, '')`.","Treat the argument to staticFile() as relative to public/, not to the project root."],"exampleFix":"// before\nconst src = staticFile('public/soundtrack.mp3');\n\n// after\nconst src = staticFile('soundtrack.mp3');","handlingStrategy":"validation","validationCode":"const safeStaticFile = (p: string) =>\n  staticFile(p.replace(/^public\\//, ''));","typeGuard":"const hasNoPublicPrefix = (p: string) => !p.startsWith('public/');","tryCatchPattern":null,"preventionTips":["Mentally treat the staticFile() argument as relative to public/, not the project root.","Lint against string literals passed to staticFile() that start with 'public/'.","Document the convention in your project's onboarding."],"tags":["staticfile","assets","path","public-folder","prefix"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}