The route `${server.config.base}__devtools__` may result in inaccessibility when using `router.use(vite.middlewares)`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 279
- PR merge metrics
- No merged PRs in 30d
Description
Recently, i tried to use devtools-next in my SSR project, but i found the error as shown in the below picture.
I found it is caused by the unnormal route /__devtools__. So i checked the route register, and i found it is registered with the path /demo/demo/__devtools__, which includes two base string demo . It is casued by these code:
const { createServer } = await import('vite')
vite = await createServer({
server: { middlewareMode: true },
appType: 'custom',
})
router.use(vite.middlewares)
...
app.use(''/demo, router);
Besides, devtools-next register a the route ${server.config.base}__devtools__ by server.middlewares.
function configureServer(server: ViteDevServer) {
const base = (server.config.base) || '/'
server.middlewares.use(`${base}__devtools__`, sirv(DIR_CLIENT, {
single: true,
dev: true,
}))
I tried to pass base: '/' when createServer(), but it will influence the whole vite build process.
So, can you remove the server.config.base in the __devtools__ route? just like the other vite middlewares did.
And let used decide how to register it.
You can refer to this demo, thanks~
https://stackblitz.com/~/github.com/zzddlalala/vitejs-vite-ghsrnu
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the configureServer entry point shown in the issue and inspect how server.middlewares registers the devtools route. Reproduce the linked SSR demo with router.use(vite.middlewares), then verify that mounting the middleware under /demo does not duplicate the Vite base path and that the devtools route remains reachable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- backend, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100