Open jktantan opened 1 year ago
Would you be able to provide a reproduction? 🙏
nuxt/nuxt#15417
nuxt/nuxt#15417
Interesting, if I downgrade to NUXT 3.6.5, then your code is working. But I try to using your code for NUXT 3.7, that is not working.
It seems like this is related to how the new Nuxt CLI works, introduced in Nuxt 3.7. https://github.com/nuxt/cli/issues/101
Thanks for the issue. I will be working on a quick solution to make it working again on nuxi 3.7 👍🏼
I hope when this is fixed the following works again
{
"name": "domain.nl",
"private": true,
"scripts": {
"dev": "nuxt dev --host local.domain.nl --https --ssl-cert local.domain.nl.pem --ssl-key local.domain.nl-key.pem"
}
}
package.json
host issue is fixed already in latest 3.7.2 cli release. Can you please confirm that? 🙏
@pi0 Replacing nuxt dev
with npx nuxi dev
> Still getting the error
- Node Version: v18.16.1
- Nuxt Version: 3.7.0
- CLI Version: 3.7.2
- Nitro Version: 2.6.2
Mixed Content: The page at 'https://local.domain.nl:3000/ild' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://local.domain.nl:24678/_nuxt/'. This request has been blocked; this endpoint must be available over WSS.
client.ts:69 [vite] failed to connect to websocket (SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.).
This worked in 3.6.5
host issue is fixed already in latest 3.7.2 cli release. Can you please confirm that? 🙏
Unfortunately, it still doesn't work.
@jktantan I meant the host. WebSocket issue is not resolved yet.
@pi0 I will open a new issue to keep things clear here.
host+ssl -> #112
With #127 (v3.7.3), you can hook into the listen
event to register a custom ws handler. Check out this example for usage.
Will be working on some upstream (nitro) fixes to fully unblock devProxy
support as well 👍🏼
With #127 (v3.7.3), you can hook into the
listen
event to register a custom ws handler. Check out this example for usage.Will be working on some upstream (nitro) fixes to fully unblock
devProxy
support as well 👍🏼
Thank you @pi0 for the information ! This help me find a workaround I use multiple Nuxt projects in iframe, in this case HMR does not work at all. @jktantan @ucw maybe can be useful for you and anyone in this case :
import { defineNuxtConfig } from "nuxt/config"
import { createProxyServer } from "httpxy"
export default defineNuxtConfig({
nitro: {
devProxy: {
// Not working
"/editor/assets/": {
target: "ws://localhost:5003/editor/assets/",
ws: true
}
}
},
hooks: {
// Workaround
listen(server) {
const proxy = createProxyServer({ target: { host: "localhost", port: 5003 } })
server.on("upgrade", (req, socket, head) => {
if (req.url === "/editor/assets/") {
proxy.ws(req, socket, head) // socket has type error by it works
}
})
}
}
})
@jenjen75 Solution worked for me. Also, this gist can be helpful: https://gist.github.com/ucw/67f7291c64777fb24341e8eae72bcd24
Can we proxy websockets still in Nuxt 3.11 when Nitro's experimental websocket support is enabled? The above workaround is no longer working for me.
same thing here. workaround was fine before upgrading to 3.11
any news regarding this issue?
Environment
Nuxt 3.7
Reproduction
Nuxt 3.7
Describe the bug
Config:
In web:
If direct connect to Websocket Server:
Additional context
No response
Logs
No response