Skip to main content
For Astro SSR or server deployments, expose same-origin routes that forward the Trfyx script and event requests.
1

Create the script route

Create src/pages/script.js.ts:
src/pages/script.js.ts
2

Create the event route

Create src/pages/api/events.ts and forward the request body to https://app.trfyx.com/api/events while preserving the visitor IP.
src/pages/api/events.ts
3

Update the tracker

Replace the default Trfyx script with the proxied path:
index.html
4

Verify installation

Deploy your Astro site and open it in a browser. Check the Network panel to confirm both script.js and /api/events requests use your domain. Then verify the visit appears in Trfyx.
For a fully static Astro site, use Managed Proxy instead of adding server routes.

Next steps

Proxy setup

Read the full proxy setup guide

Managed Proxy

Let Trfyx manage the proxy for you

Goals

Start tracking goals with Trfyx

Troubleshooting

Fix common proxy issues
Last modified on October 12, 2026