{"record":{"id":"63d5734e9f6f0775","repo":"remotion-dev/remotion","slug":"staticfile-does-not-support-relative-paths-got","errorCode":null,"errorMessage":"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","messagePattern":"staticFile\\(\\) does not support relative paths - got \"(.+?)\"\\. Instead, pass the name of a file that is inside the public/ folder\\. See: https://remotion\\.dev/docs/staticfile-relative-paths","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/static-file.ts","lineNumber":107,"sourceCode":" * @see [Documentation](https://www.remotion.dev/docs/staticfile)\n */\nexport const staticFile = (path: string) => {\n\tif (path === null) {\n\t\tthrow new TypeError('null was passed to staticFile()');\n\t}\n\n\tif (typeof path === 'undefined') {\n\t\tthrow new TypeError('undefined was passed to staticFile()');\n\t}\n\n\tif (path.startsWith('http://') || path.startsWith('https://')) {\n\t\tthrow new TypeError(\n\t\t\t`staticFile() does not support remote URLs - got \"${path}\". Instead, pass the URL without wrapping it in staticFile(). See: https://remotion.dev/docs/staticfile-remote-urls`,\n\t\t);\n\t}\n\n\tif (path.startsWith('..') || path.startsWith('./')) {\n\t\tthrow new TypeError(\n\t\t\t`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`,\n\t\t);\n\t}\n\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);","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/static-file.ts#L89-L125","documentation":"staticFile() resolves paths relative to the public/ folder root, so it does not accept `./` or `../` relative prefixes. Those would resolve against the working directory at runtime, which is not well-defined inside Remotion's bundler and would break in the Studio and during rendering.","triggerScenarios":"Calling `staticFile('./foo.png')` or `staticFile('../shared/bar.mp3')`, often because the developer copy-pasted a relative import path.","commonSituations":"Treating staticFile() like a Node import; sharing path constants between ES imports and staticFile() calls; refactoring a file layout and reusing relative paths.","solutions":["Pass only the file name relative to public/, e.g. `staticFile('foo.png')` or `staticFile('shared/bar.mp3')`.","Move the asset into the public/ folder if it currently sits outside it.","Strip leading `./` and `../` and any `public/` prefix before calling staticFile()."],"exampleFix":"// before\nconst src = staticFile('../assets/intro.mp4');\n\n// after (move assets/intro.mp4 to public/intro.mp4 first)\nconst src = staticFile('intro.mp4');","handlingStrategy":"validation","validationCode":"const safeStaticFile = (p: string) => {\n  const stripped = p.replace(/^(\\.\\.\\/|\\.\\/)+/, '');\n  return staticFile(stripped);\n};","typeGuard":"const isBarePublicPath = (p: string) =>\n  !p.startsWith('./') && !p.startsWith('../') && !p.startsWith('public/');","tryCatchPattern":null,"preventionTips":["Keep all runtime assets under public/ and reference them by name only.","Do not reuse ES module relative import paths for staticFile().","Centralize asset path constants in one file to keep them consistent."],"tags":["staticfile","assets","relative-path","path"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}