expose-port
v0.2.2
Published
Expose localhost for testing the site in mobile app or another devices
Downloads
9
Maintainers
Readme
expose-port
expose-port
is a Node.js package that allows you to expose a specified port on your local machine, either locally or globally.
Installation
You have to install expose-port
globally using npm to run this without any error:
npm install -g expose-port `
Usage
Expose a Port over Wi-Fi
By exposing the port over Wi-Fi, you can expose the port only to devices that are connected to the same Wi-Fi network.
To expose a port on your local machine, use the following command:
expose-port -w <port>
Replace <port>
with the port number you want to expose. For example:
expose-port -w 3000
This will attempt to expose port 3000 on your machine.
Expose a Port over Internet
By exposing a port globally using the -g
option, you get a URL that you can send to anyone over the internet.
To expose a port globally using ngrok, use the following command:
expose-port -g <port>
Replace <port>
with the port number you want to expose. For example:
expose-port -g 3000
This will establish a public URL for port 3000 using ngrok, allowing external access.
Note for Vite Users
If you are using Vite, you need to modify your package.json
to use the --host
option for Vite to work correctly with the exposed port. Update your package.json
scripts as follows:
"scripts": {
"dev": "vite --host"
}
Contributing
Contributions are welcome! If you would like to contribute to this project, please follow these steps:
- Fork and star😅 the repository.
- Create a new branch for your feature or bugfix (
git checkout -b feature-name
orgit checkout -b bugfix-name
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-name
orgit push origin bugfix-name
). - Open a pull request with a description of your changes.
License
This project is licensed under the MIT License - see the LICENSE file for details.