Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The route ${server.config.base}__devtools__ may result in inaccessibility when using router.use(vite.middlewares) #586

Open
zzddlalala opened this issue Aug 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@zzddlalala
Copy link

Recently, i tried to use devtools-next in my SSR project, but i found the error as shown in the below picture.
image

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.
image

You can refer to this demo, thanks~
https://stackblitz.com/~/github.com/zzddlalala/vitejs-vite-ghsrnu

@zzddlalala zzddlalala changed the title The router ${server.config.base}__devtools__ may result in inaccessibility when using router.use(vite.middlewares) The route ${server.config.base}__devtools__ may result in inaccessibility when using router.use(vite.middlewares) Aug 27, 2024
@alexzhang1030
Copy link
Member

We can introduce an option to let users manually register the devtools path. WDYT? @webfansplz

@webfansplz
Copy link
Member

We can introduce an option to let users manually register the devtools path. WDYT? @webfansplz

I agree that we can add an option to customize it.

@webfansplz webfansplz added the enhancement New feature or request label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants
@zzddlalala @webfansplz @alexzhang1030 and others