Languages

React - npm run dev showing "Network: use --host to expose" (Vite)

0 points
Asked by:
Savannah
559

Previously, when I run npm run dev command, it showed something like this:

Local: http://localhost:3000/
Network: http://192...:3000/

Now, there is no Network address but the following information instead:

Network: use --host to expose

I'm using Vite + React + TS. How can I make it work again?

1 answer
0 points
Answered by:
Savannah
559

Add the following configuration to the vite.config.ts file:

server: {
  host: true
}

Practical example:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  server: {
    host: true
  }
})
0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join