Validate webhook endpoints on localhost with Expose.sh

By Robbie | July 9, 2020

Introduction

Lets say you have a webhook integration, where an external service will ping your endpoint with useful information such as notifications, payments received or other info.

The only way to validate this integration is to trigger the external service to hit your endpoint. Using expose.sh, you can do this from your local machine.

By validating locally you’ll have access to all of your debugging tools and be able to quickly fix issues without having to deploy your code to a remote public facing server, saving whole alot of time and effort.

Install expose.sh

For Mac or Linux, go to Expose.sh and copy/paste the installation code shown into a terminal.

For Windows go to Expose.sh, download the binary and put it somewhere in your PATH.

Expose your api to the web

Start your API server. Then run expose <port> where port is the port your API server is running on, like 80 or 8080.

Expose.sh will generate a random public expose.sh URL. You’ll see output like

https://s3rh.expose.sh is forwarding to localhost:80
http://s3rh.expose.sh is forwarding to localhost:80

Trigger the external service to ping your webhook using your new expose.sh URL

Lets say your webhook endpoint is /validate-payment and its purpose is validating payments.

Using the URL https://s3rh.expose.sh from the example output above, trigger the external service to send a webhook message to https://s3rh.expose.sh/receive-payment.

Feel free to set debug breakpoints or add logging to your code so you can see the details of whats happening.

The external service will hit your endpoint, which is running on your local machine. You can then debug and make changes as needed.

Custom subdomains

Using a custom subdomain (like myapi.expose.sh) would save you from needing to enter in or reconfigure a different URL each time.

Expose.sh is free to use for randomly generated subdomains. If you want to use your own custom subdomains like “myapi.expose.sh”, you can do this for as little as $5/month depending on how many domains you want to use. Its usually a good time vs money investment, considering the hourly rate of most people who use expose.sh for work. Sign up here.

Conclusion

As you can see, using expose.sh to validate a webhook integration is much faster than doing it using a remote server. Expose.sh is free to use for random subdomains. You can use custom domains for as little as $4.99 per month.

Happy coding!