Threejs website refreshes every 20seconds?

Hi all. I’ve made a 3D website, when I run it “locally” (internal IP address in the browser) there’s no problem, the page behaves normally, no refreshes.

When I put the actual URL I want to use, for example “threejs.mywebsitename.com”, I see the exact same 3D website, but it refreshes every 20 seconds? I’ve searched the html code, tried another browser, same…

Some details:

  • webserver: nginx, proxy_pass to internal IP of the server running the threejs website
  • threejs is running with “npm run dev”, not yet “build”

Maybe because it’s not “built” yet, this is default behaviour?

Inspected the console log window, just before the refresh, I get a “Websocket connection failed” error. Will do a google search to see if I can find something to fix, but if someone knows this error, any help is appreciated!

Edit: looks like it originates from the /@vite/client code part…

Edit 2: I’ve tried a “npm run build” and moved the files to the servers web root folder (/var/www/html) and now the refresh problem is gone, so it was the @vite bundler that doesn’t like to work nicely with a proxy_pass I think…

Maybe someone else that has this problem now knows how to “fix” it…

it sounds like you might be trying to run Vite in your production deployment? Generally it isn’t used that way, it runs a dev server while developing locally, and for deployment you have Vite build into a static dist/ or build/ folder that’s pushed to your server. Vite is not installed in the server environment and shouldn’t run there.

The npm run dev and npm run build names are meaningless on their own … they do what’s in your package.json#scripts section … so we can’t really tell what you’re doing to build your code without more information.

1 Like