I struggled to find a straightforward way to host the Android Digital Asset Links file on Wix. Found bits and pieces of help on the net. Tested my code and it seems to work.
Here it goes:
- Android needs a Digital Asset Links file hosted on the website of an app to verify ownership. The link required is:
https://www.yoursite.com/.well-known/assetlinks.json
- Since hosting this file at that location was not a plausible solution on Wix (at least to me at the time of this post), we'll need to add a JS file which can spit out the same JSON data and then redirect the URL Google expects to our new link.
- Go to Dev Mode -> Enable Developer Mode and switch on the developer mode
- In the new left pane, go to {} (Public & Backend)
- Next to Backend, click on +, and create a new Javascript file with the name
http-functions.js
- Add this code:
// Import the Wix http functions API
import {ok, notFound, serverError} from 'wix-http-functions';
// Set the assetlinks variable (between the single backticks) with the content of your assetlinks.json file
let assetlinks = `[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "<Your app package>",
"sha256_cert_fingerprints": ["<Your app's SHA256>"] }
}]`
// Define http get function for your trust.txt file
export function get_assetlinks(request) {
let options = {
"headers": {
"Content-Type": "text/plain"
},
"body": assetlinks
};
return ok(options);
}
- Publish your site
- Test if the JSON is displayed by calling:
www.yoursite.com/_functions/assetlinks
Hoping that things are great so far, we'll proceed to the last and final step - URL redirection
- Go to site Settings > Marketing & SEO > SEO Tools > URL Redirect Manager
- Click on New Redirect and enter for:
Old URL: /.well-known/assetlinks.json
New URL: /_functions/assetlinks
- Test out the link www.yoursite.com/.well-known/assetlinks.json
Hope this helps someone! Better late than never.