[{"data":1,"prerenderedAt":393},["ShallowReactive",2],{"navigation_docs":3,"diagnostic-content-NITRO0025":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,"code":381,"description":382,"docsUrl":58,"extension":383,"fix":384,"framework":385,"meta":386,"navigation":387,"pack":60,"path":388,"ruleId":61,"rulePath":62,"seo":389,"severity":63,"source":64,"sourceUrl":65,"stem":390,"why":391,"__hash__":392},"diagnostics\u002Fdiagnostics\u002FNITRO0025.md","NITRO0025: Register Nitro handlers and plugins with absolute paths",{"type":52,"value":53,"toc":371},"minimark",[54,66,71,80,84,95,99,104,107,222,225,301,305,308,339,343,355,359,367],[55,56],"rule-metadata",{"category":57,"docsUrl":58,"fix":59,"pack":60,"ruleId":61,"rulePath":62,"severity":63,"source":64,"sourceUrl":65},"modules","https:\u002F\u002Fnitro.build\u002Fconfig#handlers","suggestion","vite-doctor\u002Fnitro","nitro\u002Fconfig\u002Frequire-absolute-generated-paths","\u002Fnitro\u002Frules\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},"why-it-happens","Why it happens",[72,73,74,75,79],"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 ",[76,77,78],"code",{},"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,81,83],{"id":82},"fix","Fix",[72,85,86,87,90,91,94],{},"Register the same absolute path you write the file to, for example ",[76,88,89],{},"resolve(root, '.generated\u002Fhandler.ts')",", or resolve files shipped with the package with ",[76,92,93],{},"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,96,98],{"id":97},"example","Example",[100,101,103],"h3",{"id":102},"register-generated-handlers-with-the-path-they-were-written-to","Register generated handlers with the path they were written to",[72,105,106],{},"Before",[108,109,114],"pre",{"className":110,"code":111,"language":112,"meta":113,"style":113},"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","",[76,115,116,143,174],{"__ignoreMap":113},[117,118,121,125,129,133,136,140],"span",{"class":119,"line":120},"line",1,[117,122,124],{"class":123},"spNyl","const",[117,126,128],{"class":127},"sTEyZ"," middleware ",[117,130,132],{"class":131},"sMK4o","=",[117,134,135],{"class":131}," '",[117,137,139],{"class":138},"sfazB",".generated\u002Fnitro\u002Fmiddleware.ts",[117,141,142],{"class":131},"'\n",[117,144,146,150,154,157,160,163,166,169,171],{"class":119,"line":145},2,[117,147,149],{"class":148},"s7zQu","await",[117,151,153],{"class":152},"s2Zo4"," writeFile",[117,155,156],{"class":127},"(",[117,158,159],{"class":152},"resolve",[117,161,162],{"class":127},"(root",[117,164,165],{"class":131},",",[117,167,168],{"class":127}," middleware)",[117,170,165],{"class":131},[117,172,173],{"class":127}," code)\n",[117,175,177,180,183,186,188,191,193,196,200,203,206,208,210,212,216,219],{"class":119,"line":176},3,[117,178,179],{"class":127},"nitroConfig",[117,181,182],{"class":131},".",[117,184,185],{"class":127},"handlers",[117,187,182],{"class":131},[117,189,190],{"class":152},"push",[117,192,156],{"class":127},[117,194,195],{"class":131},"{",[117,197,199],{"class":198},"swJcz"," handler",[117,201,202],{"class":131},":",[117,204,205],{"class":127}," middleware",[117,207,165],{"class":131},[117,209,205],{"class":198},[117,211,202],{"class":131},[117,213,215],{"class":214},"sfNiH"," true",[117,217,218],{"class":131}," }",[117,220,221],{"class":127},")\n",[72,223,224],{},"After",[108,226,228],{"className":110,"code":227,"language":112,"meta":113,"style":113},"const middleware = resolve(root, '.generated\u002Fnitro\u002Fmiddleware.ts')\nawait writeFile(middleware, code)\nnitroConfig.handlers.push({ handler: middleware, middleware: true })\n",[76,229,230,254,267],{"__ignoreMap":113},[117,231,232,234,236,238,241,243,245,247,249,252],{"class":119,"line":120},[117,233,124],{"class":123},[117,235,128],{"class":127},[117,237,132],{"class":131},[117,239,240],{"class":152}," resolve",[117,242,162],{"class":127},[117,244,165],{"class":131},[117,246,135],{"class":131},[117,248,139],{"class":138},[117,250,251],{"class":131},"'",[117,253,221],{"class":127},[117,255,256,258,260,263,265],{"class":119,"line":145},[117,257,149],{"class":148},[117,259,153],{"class":152},[117,261,262],{"class":127},"(middleware",[117,264,165],{"class":131},[117,266,173],{"class":127},[117,268,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299],{"class":119,"line":176},[117,270,179],{"class":127},[117,272,182],{"class":131},[117,274,185],{"class":127},[117,276,182],{"class":131},[117,278,190],{"class":152},[117,280,156],{"class":127},[117,282,195],{"class":131},[117,284,199],{"class":198},[117,286,202],{"class":131},[117,288,205],{"class":127},[117,290,165],{"class":131},[117,292,205],{"class":198},[117,294,202],{"class":131},[117,296,215],{"class":214},[117,298,218],{"class":131},[117,300,221],{"class":127},[67,302,304],{"id":303},"verify-the-fix","Verify the fix",[72,306,307],{},"Run only this rule after editing so the report stays focused on the diagnostic you are closing:",[108,309,313],{"className":310,"code":311,"language":312,"meta":113,"style":113},"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",[76,314,315],{"__ignoreMap":113},[117,316,317,321,324,327,330,333,336],{"class":119,"line":120},[117,318,320],{"class":319},"sBMFI","pnpm",[117,322,323],{"class":138}," vite-doctor",[117,325,326],{"class":138}," .",[117,328,329],{"class":138}," --framework",[117,331,332],{"class":138}," nitro",[117,334,335],{"class":138}," --rules",[117,337,338],{"class":138}," nitro\u002Fconfig\u002Frequire-absolute-generated-paths\n",[67,340,342],{"id":341},"useful-links","Useful links",[344,345,346],"ul",{},[347,348,349],"li",{},[350,351,354],"a",{"href":58,"rel":352},[353],"nofollow","Upstream docs",[67,356,358],{"id":357},"related-rule","Related rule",[344,360,361],{},[347,362,363],{},[350,364,365],{"href":62},[76,366,61],{},[368,369,370],"style",{},"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 .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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}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 .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}",{"title":113,"searchDepth":145,"depth":145,"links":372},[373,374,375,378,379,380],{"id":69,"depth":145,"text":70},{"id":82,"depth":145,"text":83},{"id":97,"depth":145,"text":98,"children":376},[377],{"id":102,"depth":176,"text":103},{"id":303,"depth":145,"text":304},{"id":341,"depth":145,"text":342},{"id":357,"depth":145,"text":358},"NITRO0025","Finds Nitro handlers and plugins that Vite plugins, Nuxt modules or Nitro modules register with relative paths.","md","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.","nitro",{},true,"\u002Fdiagnostics\u002Fnitro0025",{"title":50,"description":382},"diagnostics\u002FNITRO0025","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.","O0g0gPPPcB9aSifG0ldPc02y-XMrqndcOxPuejcc8h0",1795268818638]