Skip to main content

Using Netlify redirects as a reverse proxy

Updated over a week ago

Netlify supports redirects and rewrites which we can use as a reverse proxy from an /mida route. In your netlify.toml file, add a redirect like this:

[[redirects]]
from = "/mida/*"
to = "https://cdn.mida.so/:splat"
host = "cdn.mida.so"
status = 200
force = true

Once done, set the /mida route of your domain as the md_cdn in your Mida.so initialization like this:

<script>
window.md_cdn = 'https://www.your-domain.com/mida'
</script>
<script src="https://www.your-domain.com/mida/js/optimize.js?key=XXXXXX" />

Once updated, deploy your changes on Netlify and check that Mida.so requests are going to https://www.your-domain.com/mida by checking the network tab on your domain.

Did this answer your question?