Skip to main content
Use Next.js rewrites to route the Trfyx script and event endpoint through your own domain.
1

Add rewrites

In next.config.js:
next.config.js
If your app already uses /api/events, choose another path such as /trfyx-events and set data-api-url to that path.
2

Update the tracker

pages/_app.tsx
When src is same-origin, Trfyx sends events to /api/events by default.
3

Verify installation

Deploy your application, open the browser Network panel, and confirm both script.js and /api/events are requested from your domain. Then check that the activity appears in Trfyx.
Make sure your hosting layer preserves the original client IP. If all visitors appear from your server location, review your forwarding headers or use Managed Proxy.

Next steps

Goals

Funnels

Managed Proxy

Troubleshooting

Last modified on October 12, 2026