This guide explains how to configure a Vite project to change the port and enable network URL or set the host to true simultaneously.
By default, Vite runs on port 3000 and only listens on localhost. You can change the port and enable network URL by setting the host to true in the Vite configuration.
- Open your Vite project's
vite.config.js
file (or create one if it doesn't exist). - Add the
port
andhost
options in theserver
configuration.