How to use the command 'expose' (with examples)
Expose is an open-source tunnel application designed to facilitate the easy sharing of websites. With Expose, developers can effortlessly share their local development environments with colleagues or clients by creating secure tunnels to their local machines. This tool is incredibly helpful for web developers needing to showcase their work without deploying to a live server. More information can be found at beyondco.de/docs/expose .
Use case 1: Register your authentication token
Code:
expose token token
Motivation:
Registering your authentication token with Expose is a critical step in setting up the tool for use. The token acts as a unique identifier to authenticate your account and ensure your tunnels are securely associated with your user profile. This is a fundamental part of maintaining security and access management in your tunneling activities, as it prevents unauthorized usage of your tunnels.
Explanation:
expose
: The command to initiate the Expose application.token
: An argument to indicate that you are registering or updating an authentication token.token
: This placeholder should be replaced with your actual authentication token. The token can often be acquired from the Expose dashboard once you have registered for an account.
Example Output:
Your token has been successfully registered
This signifies that your token was accepted, and your account can now be used to set up secure tunnels.
Use case 2: Share the current working directory
Code:
expose
Motivation:
Sharing the current working directory is a straightforward use case for developers who need to quickly expose their local development environment to an external audience. This can be particularly useful for displaying progress, obtaining client feedback, or collaborating on development without the overhead of committing to a cloud development platform.
Explanation:
expose
: This command alone tells Expose to create a tunnel to the current directory. No further arguments are needed; by default, Expose will choose an available public URL to connect to your localhost environment.
Example Output:
Tunneling to 'your-random-subdomain.expose.beyondco.de' to localhost:80
Here, Expose has successfully assigned your project a public URL that is linked to your local server.
Use case 3: Share the current working directory with a specific subdomain
Code:
expose --subdomain=subdomain
Motivation:
Using a specific subdomain when sharing your working directory provides better control and personalization of the URL associated with your project. This is particularly beneficial in collaborative projects where various stakeholders need to access clearly labeled project parts. It also aids in avoiding confusion and provides a branded experience if the subdomain matches your company or project name.
Explanation:
expose
: Initiates the Expose application.--subdomain=subdomain
: This specifies a subdomain of your choice. This string should be replaced by the actual subdomain you desire.
Example Output:
Tunneling to 'subdomain.expose.beyondco.de' to localhost:80
Now, the URL is not a randomly assigned subdomain but the one you selected, ensuring clarity and intentionality in web access.
Use case 4: Share a local URL
Code:
expose share url
Motivation:
Sharing a specific local URL is useful when you want to expose particular routes of your application instead of the entire working directory. This can be handy when you need to demo specific functionalities of a web app without exposing unfinished or non-public sections. It’s a more secure way to give access when finer granularity is needed.
Explanation:
expose
: Again, this starts the Expose application.share
: Indicates that a specific service or URL will be shared.url
: This placeholder represents the specific local URL you wish to expose. Replace it with the actual URL such ashttp://localhost:3000
.
Example Output:
Tunneling to 'random-subdomain.expose.beyondco.de' to url
The URL is now mapped to a public access point, enabling external viewers to interact with the designated part of the application.
Use case 5: Run the Expose server
Code:
expose serve
Motivation:
Running the Expose server itself allows you to serve multiple tunnels, providing flexibility in managing multiple projects or environments. It’s useful in larger spatial networks where different projects might need tunneling simultaneously, and one server acts as a tunnel broker.
Explanation:
expose
: The main command to start Expose.serve
: This denotes the command to start the server, which acts as a host for managing client connections and tunnels.
Example Output:
Expose server is running at localhost:8080
This output informs you that the server is up and running, ready to handle incoming tunnels.
Use case 6: Run the Expose server with a specific hostname
Code:
expose serve hostname
Motivation:
Starting the Expose server with a specific hostname allows administrators to specify on which domain or IP address the server should listen, providing more controlled and secure network configurations. This capability is incredibly important in environments where network architecture requires specific routing configurations or security policies.
Explanation:
expose
: Begins the Expose application.serve
: Indicates the initiation of a server.hostname
: A placeholder to be replaced by the actual hostname or IP address you wish the server to bind to, such asexpose.local
or192.168.1.1
.
Example Output:
Expose server is running at hostname:8080
The output confirms that the server is successfully running with the specified hostname, ready to manage tunneling operations.
Conclusion:
In summary, the Expose command offers a flexible, secure, and streamlined way to share local development environments with remote viewers. Each of these use cases demonstrates how developers and teams can leverage Expose to enhance productivity, collaboration, and access management across various network configurations. Whether sharing a simple directory or running a server, Expose simplifies the process, ensuring that remote demonstrations and collaborations are both efficient and secure.