Feb 18, 2025 By Median 4 min
Our team of experts collaborate on top-notch app content for sidebar Magazine.
TL;DR: Use Cloudflare Workers to serve AASA and assetlinks.json files for iOS and Android app linking when your platform doesn’t allow direct hosting. Use Median's Deep Linking Validator to ensure the correct setup without affecting your website’s regular traffic.
Is your web platform preventing you from hosting essential files for app linking, such as the Apple App Site Association (AASA) or Android Digital Asset Links (assetlinks.json)? If so, Cloudflare Workers offer a simple solution to this common problem.
Below, we’ll explain how you can leverage Cloudflare Workers (via the Cloudflare dashboard) to serve your Apple App Site Association (AASA) file and Digital Asset Links (assetlinks.json) file.
(This technique is especially useful if you own your domain but use a web platform that does not allow you to host these files directly.)
Let’s get started.
If your web platform doesn't let you place files at the required paths for iOS and Android app linking, Cloudflare Workers can help.
With this setup, Cloudflare intercepts requests to those specific paths (like /apple-app-site-association and /.well-known/assetlinks.json) and serves the necessary JSON files directly from its edge network.
Meanwhile, all other requests continue to be routed to your website as usual.
Paste the following code into the Cloudflare Workers editor:
// JSON data for the Apple App Site Association file
const aasaData = {
"applinks": {
"apps": [],
"details": [{
"appID": "TEAMID.co.median.example",
"paths": ["*"]
}]
}
};
// JSON data for the Android Digital Asset Links file
const assetlinksData = [
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "co.median.android.padzoa",
"sha256_cert_fingerprints": [
"ED:30:0F:A9:AB:9D:00:34:9D:48:B0:91:69:83:D7:C9:FE:0A:95:FE:F2:E0:38:25:C9:97:37:D8:F3:16:0B:E0"
]
}
}
];
// Worker event listener that routes requests
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const url = new URL(request.url);
// Serve the Apple App Site Association file
if (url.pathname === '/apple-app-site-association') {
return new Response(JSON.stringify(aasaData, null, 2), {
headers: { 'Content-Type': 'application/json' }
});
}
// Serve the assetlinks.json file
if (url.pathname === '/.well-known/assetlinks.json') {
return new Response(JSON.stringify(assetlinksData, null, 2), {
headers: { 'Content-Type': 'application/json' }
});
}
// Return a 404 response for any other paths
return new Response('Not found', { status: 404 });
}
Get hands-on with Median’s comprehensive documentation, and build your app with ease.
After deploying your Worker, use your browser to verify that the necessary endpoints are working correctly:
After confirming that your endpoints and homepage work correctly, validate your deep linking setup to ensure both iOS and Android configurations are recognized.
This step ensures that your deep linking configurations are properly set up and recognized by mobile devices.
Launch a full-feature native app without native development!
Using Cloudflare Workers to serve AASA and assetlinks files allows for a seamless way to enable app linking when your platform doesn’t support direct file hosting. Adjust the JSON data in the code as needed and manage deployment entirely through the Cloudflare dashboard.
This approach keeps your site running smoothly while ensuring your app is compatible with both Android and iOS devices.
Once set up, validate your deep linking configuration with Median’s Deep Linking Validator to ensure your iOS and Android links are fully functional. This gives you full control over your app linking without needing to modify your existing web infrastructure.
Join our mailing list for the latest mobile app news & Median updates.