By Robbie | July 20, 2020
This tutorial will show you how to test AfterShip Webhooks locally.
Lets say I’m using AfterShip and I want to receive Webhook notifications for one or more scenarios.
The only way to validate this integration is to trigger AfterShip to hit a public endpoint. Using expose.sh, you can instantly give your local machine a public endpoint, saving you from having to deploy your code to a remote server.
By testing locally you’ll have access to all of your development and debugging tools and be able to quickly make changes and fix issues without redeploying code remotely.
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.
Get a public URL for your local machine
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 that forwards to your local machine.
Heres a full example where I have a server running locally on port 80:
expose 80 https://s3rh.expose.sh is forwarding to localhost:80 http://s3rh.expose.sh is forwarding to localhost:80
Thats all there is to it. You now have a public URL for your local machine. This URL should work even if you have a firewall or other network boundaries in the way, because it sets up a tunnel between expose.sh and your machine.
Trigger AfterShip to hit your Webhook endpoint using your new expose.sh URL
Now, do something that will trigger a AfterShip Webhook. When AfterShip hits your new expose.sh endpoint, the request will be forwarded to your local machine. You can then debug and make changes as needed.
Using a custom subdomain like myapi.expose.sh would save you from needing to reconfigure a different URL each time in AfterShip.
Expose.sh is free to use for randomly generated subdomains. If you want to use custom subdomains you can do this for as little as $4.99/month depending on how many subdomains you want to use. Sign up here
As you can see, using expose.sh to validate a AfterShip Webhook integration is much faster than doing it using a remote server.
Happy coding!Get started here