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 port used for devtools integration can't be configured #200

Open
ohmree opened this issue Jun 22, 2021 · 3 comments
Open

The port used for devtools integration can't be configured #200

ohmree opened this issue Jun 22, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@ohmree
Copy link

ohmree commented Jun 22, 2021

Describe the bug

I'm using windi with phoenix liveview and vite, with the vite dev server serving on port 3000 and phoenix on port 4000 (phoenix <-> vite integration was achieved using vite_phx).

It seems like by default the js resulting from importing virtual:windi-devtools sends a post request to /@windicss-devtools-update, which in my case I guess means port 4000 as opposed to 3000.
This results in a 404 from phoenix, whereas if I send a plain get request to localhost:3000/@windicss-devtools-update the status code changes to 500, which makes me think this might indeed be the issue.
Furthermore, sending a get request to localhost:3000/foobar also results in a 404, which contributes to my hypothesis above.

Minimal Reproductions
It took me quite a while to get this set up so there isn't anything quick I can link, but I think adding a way to configure the port used in the request mentioned above should be easily doable without adding much maintenance burden.

Versions

  • vite-plugin-windicss: 1.0.4
  • vite: 2.3.8
  • framework(vue/react/svelte/etc): phoenix 1.5.9, liveview 0.15.1
@ohmree ohmree added the bug Something isn't working label Jun 22, 2021
@antfu
Copy link
Member

antfu commented Jun 22, 2021

It reuses Vite's server port, isn't that a case in phoenix?

@ohmree
Copy link
Author

ohmree commented Jun 22, 2021

It reuses Vite's server port, isn't that a case in phoenix?

The port that's actually used is vite's server port (3000), but the js that's generated from importing virtual:windi-devtools tries to send a post request to port 4000 (aka just / without specifying a port), resulting in the following error:

XHR POST http://localhost:4000/@windicss-devtools-update [HTTP/1.1 404 Not Found 190ms]

@ElMassimo
Copy link
Collaborator

ElMassimo commented Jul 14, 2022

Confirming this is also a problem for Vite Ruby projects, I'll try to make a pull request when I have some time.

Perhaps it could use a similar fallback as vitejs/vite#8650, by using the server.hmr.clientPort if available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants