I’m trying to set up an environment in which vite’s hot reload is available through traefik’s reverse proxy. For this, I noticed that it is necessary to add a certificate in the vite settings vite.config.js
.
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
// import mkcert from 'vite-plugin-mkcert';
export default defineConfig({
server: {
// https: true,
host: '0.0.0.0',
hmr: {
host: '0.0.0.0'
},
},
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
// mkcert()
],
});
The code above works correctly for localhost. When I use vite-plugin-mkcert I get the following error with npm run dev
:
error when starting dev server:
Error: EACCES: permission denied, mkdir ‘/root/.vite-plugin-mkcert’
I tried installing the package using --unsafe-perm=true
--allow-root
options, but it didn’t work.
The whole environment is inside docker and other packages don’t have the same problem.
My container uses the root user.
2
Answers
Solved in the following way:
Now I don't need the package anymore and hot-reload works with reverse proxy.
Include your host without http/https, make sure that you have installed mkcert.
After setting up you need to run npm with https