Proxying Ackee through Netlify

Jun 29, 2022

2 min. read

Proxying the requests to Ackee through Netlify comes with some advantages:

Netlify Redirects can redirect requests to external services and this is how we will be setting up our proxy rewrites.

Adding the rewrite rules

Netlify Redirects rules are configured in a file called _redirects. Create the file if you do not have one already. Here are the rules to use:

/script.js https://your-ackee-domain.com/tracker.js 200
/api https://your-ackee-domain.com/api 200

What we have done is proxying these paths to an external path on another domain:

https://yourdomain.com/script.js -> https://your-ackee-domain.com/tracker.js
https://yourdomain.com/api -> https://your-ackee-domain.com/api

Update the path in your script tag

You will need to update the Ackee script to reference the new path:

<script
async
src="/script.js"
data-ackee-server="https://yourdomain.com"
data-ackee-domain-id="0000-0000-0000-0000-0000"
>
</script>

Verify the changes

Verify the proxy is working by seeing your website making requests to /script.js and /api and that they respond with status 200.

Leave a comment