[{"data":1,"prerenderedAt":385},["ShallowReactive",2],{"navigation_docs":3,"rule-content-\u002Fnitro\u002Frules\u002Fconfig\u002Frequire-absolute-generated-paths":48},[4,8,12,16,20,24,28,32,36,40,44],{"title":5,"path":6,"stem":7},"CLI","\u002Fcli","1.cli",{"title":9,"path":10,"stem":11},"Nuxt","\u002Fnuxt","2.nuxt",{"title":13,"path":14,"stem":15},"Vue","\u002Fvue","3.vue",{"title":17,"path":18,"stem":19},"Vite","\u002Fvite","4.vite",{"title":21,"path":22,"stem":23},"Nitro","\u002Fnitro","5.nitro",{"title":25,"path":26,"stem":27},"TypeScript","\u002Ftypescript","6.typescript",{"title":29,"path":30,"stem":31},"shadcn","\u002Fshadcn","7.shadcn",{"title":33,"path":34,"stem":35},"Package","\u002Fpackage","8.package",{"title":37,"path":38,"stem":39},"Extending Doctor","\u002Fextending","9.extending",{"title":41,"path":42,"stem":43},"MCP","\u002Fmcp","9.mcp",{"title":45,"path":46,"stem":47},"Pinia","\u002Fpinia","9.pinia",{"id":49,"title":50,"body":51,"category":57,"description":372,"diagnosticCodes":373,"docsUrl":59,"extension":374,"fix":60,"framework":375,"meta":376,"navigation":377,"pack":61,"path":379,"recommendedReplacement":380,"ruleId":62,"seo":381,"severity":63,"source":64,"sourceUrl":65,"stem":382,"why":383,"__hash__":384},"rules\u002Fnitro\u002Frules\u002Fconfig\u002Frequire-absolute-generated-paths.md","Register Nitro handlers and plugins with absolute paths",{"type":52,"value":53,"toc":363},"minimark",[54,66,71,109,113,121,125,136,140,159,163,168,171,280,283,359],[55,56],"rule-metadata",{"category":57,"diagnosticCodes":58,"docsUrl":59,"fix":60,"pack":61,"ruleId":62,"severity":63,"source":64,"sourceUrl":65},"modules","NITRO0025","https:\u002F\u002Fnitro.build\u002Fconfig#handlers","suggestion","vite-doctor\u002Fnitro","nitro\u002Fconfig\u002Frequire-absolute-generated-paths","warn","src\u002Frule-packs\u002Fnitro\u002Frules\u002Frequire-absolute-generated-paths.ts","https:\u002F\u002Fgithub.com\u002Fonmax\u002Fvite-doctor\u002Fblob\u002Fmain\u002Fsrc\u002Frule-packs\u002Fnitro\u002Frules\u002Frequire-absolute-generated-paths.ts",[67,68,70],"h2",{"id":69},"run-this-rule","Run this rule",[72,73,78],"pre",{"className":74,"code":75,"language":76,"meta":77,"style":77},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm vite-doctor . --framework nitro --rules nitro\u002Fconfig\u002Frequire-absolute-generated-paths\n","bash","",[79,80,81],"code",{"__ignoreMap":77},[82,83,86,90,94,97,100,103,106],"span",{"class":84,"line":85},"line",1,[82,87,89],{"class":88},"sBMFI","pnpm",[82,91,93],{"class":92},"sfazB"," vite-doctor",[82,95,96],{"class":92}," .",[82,98,99],{"class":92}," --framework",[82,101,102],{"class":92}," nitro",[82,104,105],{"class":92}," --rules",[82,107,108],{"class":92}," nitro\u002Fconfig\u002Frequire-absolute-generated-paths\n",[67,110,112],{"id":111},"why-it-matters","Why it matters",[114,115,116,117,120],"p",{},"Nitro does not resolve a registered path against the file that registers it. Nitro 2 and Nitro 3 resolve handler and plugin paths against Nitro’s project rootDir. A generated file written to ",[79,118,119],{},"resolve(root, '.vitehub\u002Fhandler.ts')"," but registered as '.vitehub\u002Fhandler.ts' only works while every root happens to match, and it breaks for monorepos, custom srcDir or Vite roots, and Nitro 2.",[67,122,124],{"id":123},"recommended-fix","Recommended fix",[114,126,127,128,131,132,135],{},"Register the same absolute path you write the file to, for example ",[79,129,130],{},"resolve(root, '.generated\u002Fhandler.ts')",", or resolve files shipped with the package with ",[79,133,134],{},"createResolver(import.meta.url)",". Doctor checks files that import from vite, nitro, nitropack, @nuxt\u002Fkit or @nuxt\u002Fschema, and skips config files, tests, app and server runtime directories, and arguments of @nuxt\u002Fkit helpers, which nuxt\u002Fmodule\u002Fresolve-runtime-paths reports. It checks relative literals and const paths in handler objects with a route, middleware, method or lazy key, and in Nitro plugins arrays. For addPlugin and addServerPlugin calls on builders created by named imports of createNitroServerKit or createNitroConfigKit, Doctor compares an explicit Nitro root with writes on the registration path, including straight-line writes in awaited local helpers. It skips the Diagnostic when a competing write might already reach Nitro's destination. When the Nitro options come from a parameter, Doctor also checks separate helpers that share the same path constant when there is a single matching write and the roots come from separate inputs that can diverge.",[67,137,139],{"id":138},"useful-links","Useful links",[141,142,143,152],"ul",{},[144,145,146],"li",{},[147,148,151],"a",{"href":59,"rel":149},[150],"nofollow","Rule reference",[144,153,154],{},[147,155,158],{"href":156,"rel":157},"https:\u002F\u002Fnitro.build\u002Fguide\u002Frouting",[150],"Nitro handlers",[67,160,162],{"id":161},"example","Example",[164,165,167],"h3",{"id":166},"register-generated-handlers-with-the-path-they-were-written-to","Register generated handlers with the path they were written to",[114,169,170],{},"Before",[72,172,176],{"className":173,"code":174,"language":175,"meta":77,"style":77},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const middleware = '.generated\u002Fnitro\u002Fmiddleware.ts'\nawait writeFile(resolve(root, middleware), code)\nnitroConfig.handlers.push({ handler: middleware, middleware: true })\n","ts",[79,177,178,201,232],{"__ignoreMap":77},[82,179,180,184,188,192,195,198],{"class":84,"line":85},[82,181,183],{"class":182},"spNyl","const",[82,185,187],{"class":186},"sTEyZ"," middleware ",[82,189,191],{"class":190},"sMK4o","=",[82,193,194],{"class":190}," '",[82,196,197],{"class":92},".generated\u002Fnitro\u002Fmiddleware.ts",[82,199,200],{"class":190},"'\n",[82,202,204,208,212,215,218,221,224,227,229],{"class":84,"line":203},2,[82,205,207],{"class":206},"s7zQu","await",[82,209,211],{"class":210},"s2Zo4"," writeFile",[82,213,214],{"class":186},"(",[82,216,217],{"class":210},"resolve",[82,219,220],{"class":186},"(root",[82,222,223],{"class":190},",",[82,225,226],{"class":186}," middleware)",[82,228,223],{"class":190},[82,230,231],{"class":186}," code)\n",[82,233,235,238,241,244,246,249,251,254,258,261,264,266,268,270,274,277],{"class":84,"line":234},3,[82,236,237],{"class":186},"nitroConfig",[82,239,240],{"class":190},".",[82,242,243],{"class":186},"handlers",[82,245,240],{"class":190},[82,247,248],{"class":210},"push",[82,250,214],{"class":186},[82,252,253],{"class":190},"{",[82,255,257],{"class":256},"swJcz"," handler",[82,259,260],{"class":190},":",[82,262,263],{"class":186}," middleware",[82,265,223],{"class":190},[82,267,263],{"class":256},[82,269,260],{"class":190},[82,271,273],{"class":272},"sfNiH"," true",[82,275,276],{"class":190}," }",[82,278,279],{"class":186},")\n",[114,281,282],{},"After",[72,284,286],{"className":173,"code":285,"language":175,"meta":77,"style":77},"const middleware = resolve(root, '.generated\u002Fnitro\u002Fmiddleware.ts')\nawait writeFile(middleware, code)\nnitroConfig.handlers.push({ handler: middleware, middleware: true })\n",[79,287,288,312,325],{"__ignoreMap":77},[82,289,290,292,294,296,299,301,303,305,307,310],{"class":84,"line":85},[82,291,183],{"class":182},[82,293,187],{"class":186},[82,295,191],{"class":190},[82,297,298],{"class":210}," resolve",[82,300,220],{"class":186},[82,302,223],{"class":190},[82,304,194],{"class":190},[82,306,197],{"class":92},[82,308,309],{"class":190},"'",[82,311,279],{"class":186},[82,313,314,316,318,321,323],{"class":84,"line":203},[82,315,207],{"class":206},[82,317,211],{"class":210},[82,319,320],{"class":186},"(middleware",[82,322,223],{"class":190},[82,324,231],{"class":186},[82,326,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357],{"class":84,"line":234},[82,328,237],{"class":186},[82,330,240],{"class":190},[82,332,243],{"class":186},[82,334,240],{"class":190},[82,336,248],{"class":210},[82,338,214],{"class":186},[82,340,253],{"class":190},[82,342,257],{"class":256},[82,344,260],{"class":190},[82,346,263],{"class":186},[82,348,223],{"class":190},[82,350,263],{"class":256},[82,352,260],{"class":190},[82,354,273],{"class":272},[82,356,276],{"class":190},[82,358,279],{"class":186},[360,361,362],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":77,"searchDepth":203,"depth":203,"links":364},[365,366,367,368,369],{"id":69,"depth":203,"text":70},{"id":111,"depth":203,"text":112},{"id":123,"depth":203,"text":124},{"id":138,"depth":203,"text":139},{"id":161,"depth":203,"text":162,"children":370},[371],{"id":166,"depth":234,"text":167},"Finds Nitro handlers and plugins that Vite plugins, Nuxt modules or Nitro modules register with relative paths.",[58],"md","nitro",{},{"title":378},"Generated paths","\u002Fnitro\u002Frules\u002Fconfig\u002Frequire-absolute-generated-paths","Register the same absolute path you write the file to, for example resolve(root, '.generated\u002Fhandler.ts'), or resolve files shipped with the package with createResolver(import.meta.url). Doctor checks files that import from vite, nitro, nitropack, @nuxt\u002Fkit or @nuxt\u002Fschema, and skips config files, tests, app and server runtime directories, and arguments of @nuxt\u002Fkit helpers, which nuxt\u002Fmodule\u002Fresolve-runtime-paths reports. It checks relative literals and const paths in handler objects with a route, middleware, method or lazy key, and in Nitro plugins arrays. For addPlugin and addServerPlugin calls on builders created by named imports of createNitroServerKit or createNitroConfigKit, Doctor compares an explicit Nitro root with writes on the registration path, including straight-line writes in awaited local helpers. It skips the Diagnostic when a competing write might already reach Nitro's destination. When the Nitro options come from a parameter, Doctor also checks separate helpers that share the same path constant when there is a single matching write and the roots come from separate inputs that can diverge.",{"title":50,"description":372},"nitro\u002Frules\u002Fconfig\u002Frequire-absolute-generated-paths","Nitro does not resolve a registered path against the file that registers it. Nitro 2 and Nitro 3 resolve handler and plugin paths against Nitro’s project rootDir. A generated file written to resolve(root, '.vitehub\u002Fhandler.ts') but registered as '.vitehub\u002Fhandler.ts' only works while every root happens to match, and it breaks for monorepos, custom srcDir or Vite roots, and Nitro 2.","IedfE2HVVyP-6XzdwKmLNPtcyfwMU3YcxueiRdy-Xf8",1795268796314]