Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/devtools-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
postHandler as htmlValidatePost,
deleteHandler as htmlValidateDelete,
} from './runtime/html-validate/api-handlers'
import { addDevServerHandler } from '@nuxt/kit'

export {
getHydrationMismatches,
Expand All @@ -30,8 +31,10 @@ export {
clearHtmlValidateReport,
}

export function createHintsRouter() {
const router = createRouter()
function createHintsRouter() {
const router = createRouter({
preemptive: true,
})

router.get('/hydration', hydrationGet)
router.post('/hydration', hydrationPost)
Expand All @@ -47,3 +50,12 @@ export function createHintsRouter() {

return router
}

export function registerDevServerHandlers() {
const router = createHintsRouter()

addDevServerHandler({
route: '/__nuxt_hints',
handler: router.handler,
})
}
7 changes: 2 additions & 5 deletions src/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { joinURL } from 'ufo'
import type { HintsClientFunctions, HintsServerFunctions } from './runtime/core/rpc-types'
import { RPC_NAMESPACE } from './runtime/core/rpc-types'
import {
createHintsRouter,
getHydrationMismatches,
clearHydrationMismatches,
getLazyLoadHints,
clearLazyLoadHint,
getHtmlValidateReports,
clearHtmlValidateReport,
registerDevServerHandlers,
} from './devtools-handlers'

const DEVTOOLS_UI_ROUTE = '/__nuxt-hints'
Expand Down Expand Up @@ -54,10 +54,7 @@ export function setupDevToolsUI(nuxt: Nuxt, resolver: Resolver) {
},
}, nuxt)

addDevServerHandler({
route: '/__nuxt_hints',
handler: createHintsRouter().handler,
})
registerDevServerHandlers()

onDevToolsInitialized(() => {
const rpc = extendServerRpc<HintsClientFunctions, HintsServerFunctions>(RPC_NAMESPACE, {
Expand Down
Loading