Layercode needs to send a webhook to your backend to generate agent responses. If you’re running your backend locally, you’ll need to expose it to the internet using a tunnel service.
Setting up a tunnel with cloudflared
We recommend using cloudflared, which is free for development.Install cloudflared
- macOS:
brew install cloudflared - Windows:
winget install --id Cloudflare.cloudflared - Other platforms
Copy your tunnel URL
After starting, cloudflared will print a public URL in your terminal, e.g.:Add the path of your backend’s webhook endpoint to the URL, e.g.:
/api/agent is just an example. Your actual endpoint may be different depending on your backend configuration.Update your Layercode agent
- Go to the Layercode dashboard.
- Click on your agent.
- Click the Edit button in the ‘Your Backend’ box.
- Enter your Webhook URL (from the previous step) and ensure your
LAYERCODE_WEBHOOK_SECRETmatches your environment variable.
Alternative Tunneling Solutions
Besides cloudflared, you can also use other tunneling solutions like ngrok to expose your local backend.If using Vite:
By default, Vite blocks requests from other hosts, so you will need to add your Cloudflared (or ngrok, etc.) address tovite.config.ts in server.allowedHosts.
For example: