Vercel supports rewrites which we can use as a reverse proxy. Create a vercel.json file and add a rewrites object from the /mida route.
{
"rewrites": [
{
"source": "/mida/:path*",
"destination": "https://cdn.mida.so/:path*"
}
]
}
Some frameworks, like SvelteKit and Astro, require a hungrier regex pattern like:
{
"rewrites": [
{
"source": "/mida/:path(.*)",
"destination": "https://cdn.mida.so/:path*"
}
]
}
Note: Some frameworks, like T3 app, don't support Vercel rewrites well. If neither of these options work, we recommend trying another proxy method.
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' </script> <script src="https://www.your-domain.com/mida/js/optimize.js?key=XXXXXX" />
Once updated, deploy your changes on Vercel and check that Mida.so requests are going to https://www.your-domain.com/ by checking the network tab on your domain.
