Share vite projects locally using nip.io. This currently handles only CraftCMS and Laravel projects.
ddev share-local
Bind Vite to all interfaces and set the correct origin when currently sharing:
// vite.config.js
const url = new URL(process.env.SHARE_URL ?? process.env.DDEV_PRIMARY_URL)
export default defineConfig({
// …
server: {
host: '0.0.0.0',
port: 5173,
strictPort: true,
origin: `${url.origin}:5173`,
hmr: {
protocol: "wss",
host: url.host
}
},
// …
});