Skip to content

Commit a57b36e

Browse files
committed
Add Create A Public URL For A Local Server as a workflow til
1 parent 22e4a1e commit a57b36e

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1212

13-
_1111 TILs and counting..._
13+
_1112 TILs and counting..._
1414

1515
---
1616

@@ -1290,6 +1290,7 @@ _1111 TILs and counting..._
12901290

12911291
- [Change Window Name In iTerm](workflow/change-window-name-in-iterm.md)
12921292
- [Convert An ePub Document To PDF On Mac](workflow/convert-an-epub-document-to-pdf-on-mac.md)
1293+
- [Create A Public URL For A Local Server](workflow/create-a-public-url-for-a-local-server.md)
12931294
- [Enable Dev Tools For Safari](workflow/enable-dev-tools-for-safari.md)
12941295
- [Forward Stripe Events To Local Server](workflow/forward-stripe-events-to-local-server.md)
12951296
- [Get Your Public IP Address](workflow/get-your-public-ip-address.md)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Create A Public URL For A Local Server
2+
3+
At times while developing an app locally, you need to expose the local server
4+
to the public internet. This can be useful and necessary when working on a
5+
3rd-party integration or when you want to show what you have running locally to
6+
someone else.
7+
8+
In addition to tools like [ngrok](https://ngrok.com/), I've found the
9+
[`localtunnel`](https://github.com/localtunnel/localtunnel) npm package to be
10+
an effective way to quickly expose a localhost port.
11+
12+
```
13+
$ npx localtunnel --port 3000 --subdomain some-custom-subdomain
14+
your url is: https://some-custom-subdomain.loca.lt
15+
```
16+
17+
This will create a `loca.lt` URL with the given subdomain that tunnels
18+
requests to `localhost:3000`. If the `--subdomain` flag is not specified or
19+
what you've specified isn't available, `localtunnel` will generate a random
20+
subdomain.
21+
22+
For the subdomain, I recommend using something sufficiently unique like
23+
`josh-branchaud-04092021`. Using the date has the added benefit of
24+
contextualizing when I generated the URL.
25+
26+
In my experience, these are not long-lived domains. Sometimes the connection
27+
gets interrupted and you'll have to restart it. Often when restarting, the
28+
specified subdomain will then be flagged as unavailable, so you have to tweak
29+
it a little.
30+
31+
Because it is using `npx`, there is nothing to install as long as you already
32+
have `node` itself installed.

0 commit comments

Comments
 (0)