N
Nuxt3mo ago
Imran

Nuxt dev server from code server

I started a dev server(hmr) from a self hosted code-server. Code server serves from https://example.com/proxy/3000. the dev servers runs but assets(css,js,images) don't load properly. I figured it has something to do with proxying but I'm unsure how to go about it, I assume i should proxy https://example.com to https://example.com/proxy/3000. But i don't know if to use the vite, app, or nitro dev proxy option.
12 Replies
Jacek
Jacek3mo ago
Try baseUrl (docs)
Imran
ImranOP3mo ago
@Jacek Made some progress, lotf of the assets load now but some still don't load properly maybe it has something to do with hmr?
Jacek
Jacek3mo ago
Seems unlikely, but I cannot rule it out since I have very little knowledge about your project setup. Is there anything interesting in DevTools Network tab?
Imran
ImranOP3mo ago
@Jacek Sorry about the late reply. It says
[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.).
[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.).
Orbis
Orbis3mo ago
Dont load = HMR or initially? I think vite uses ws at some port notify hmr You need to proxy that too If you want to temporarly deploy your dev state somewhere, you might better use a tunnel (e.g. localtunnel)
Jacek
Jacek3mo ago
Examples showing WS usage usually include protocol adjustment
const isSecure = location.protocol === "https:";
const url = (isSecure ? "wss://" : "ws://") + location.host + "/_ws";
const isSecure = location.protocol === "https:";
const url = (isSecure ? "wss://" : "ws://") + location.host + "/_ws";
let me know if it helps 🙂
Imran
ImranOP3mo ago
It doesn't hot module reload. I have coder server running on a vps i want to be able to run a dev server from there, hope this makes sense. Where do i include this? as a middleware or?
Jacek
Jacek3mo ago
Apologies, I through the error is related to your own use of WebSockets. In case of HMR.. it should be there already. Maybe devServer » https could help force Vite to realize it is loaded with with TLS and switch to wss://.
Imran
ImranOP3mo ago
Does this have the same effect as running
nuxi dev --https
nuxi dev --https
? @Jacek When i tried that it says socket hangup
Doggnutts586
Doggnutts5863mo ago
Hey
Imran
ImranOP3mo ago
Hello
Jacek
Jacek3mo ago
It might be the same. Have you tried suggestion from #16377 yet?
Want results from more Discord servers?
Add your server