-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Using ngrok with npm run dev
causes infinite reloads
#1975
Comments
This is essentially a duplicate of #1134 in that it is caused by Vite reloading the page when it can't reach its own HMR websocket server. |
What is the fix for this? |
I was struggling with this very issue using Ngrok with SvelteKit v1.0.0-next.288. The problem is the default websocket port (3000) was not connecting because Ngrok doesn't accept requests on that port. You can see the failure in your Network panel. There's usually a pending request that never connects to The fix for this is to set the port for HMR to the default web traffic ports of 80 or 443 (HTTP or HTTPS, respectively), so the request for the websocket connection gets requested to the appropriate port on Ngrok. Ngrok then forwards that request to your aliased localhost port (3000, if using SvelteKit's default). For me, I was running HTTPS on Ngrok, and default port (3000) for SvelteKit. So, I configured port 443 (default for HTTPS) for HMR so that the websocket request goes through Ngrok's port and forwarded to 3000 on my localhost. Here's my const config = {
build: {
sourcemap: 'inline',
},
kit: {
adapter: adapter(),
vite: {
server: {
hmr: {
port: 443 // <--- The appropriate Ngrok port
}
}
}
},
preprocess: preprocess(),
}; To verify the fix, go back to your Network panel in your browser, and hopefully you'll see a successful connection to |
Describe the bug
It seem that when using something like ngrok and loading a sveltekit app via
npm run dev
, the pages keep reloading in an infinite loop. Is this a vite issue?Reproduction
ngrok config:
foobar.ngrok.io
in your browserLogs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: