-
Hello, I am trying to host vite in a php-apache container, but I cannot access it in the browser. The web console gives the error As for the docker container, I simply use docker-compose with the 5173:5173 and 80:80 ports exposed. The Dockerfile has some additional configuration to install node. The most vital part is probably the vite configuration file vite.config.js which is set up like this:
I tried several different configurations, but none works. What I have left to do is to setup a node container directly, just in case something in the apache server blocks access to vite. Something else I could try? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Alright, I got it working by setting host: true, remove ports from the hmr section, adding
and change the port to 8000 |
Beta Was this translation helpful? Give feedback.
-
Fixed this by server: {
host: 'node', // node container in docker
origin: 'http://localhost:5173', // exposed node container address
}, |
Beta Was this translation helpful? Give feedback.
-
In case you are using HTTPS: server: { |
Beta Was this translation helpful? Give feedback.
-
In case someone else runs into this, I fixed mine by switching host to 0.0.0.0 when running in docker server: {
port: 3000,
host: '0.0.0.0',
}, |
Beta Was this translation helpful? Give feedback.
Alright, I got it working by setting host: true, remove ports from the hmr section, adding
and change the port to 8000