Your Baby’s First Word Will Be JSON

Arpith Siromoney
Nov 15, 2015 · 1 min read

I ended yesterday’s post (on using a link to sign in to an app) by promising to try out iOS 9’s Universal Links. To do this, you need to serve a JSON file at yourDomain.com/apple-app-site-association — this is a quick way to do that.

There are two steps to this:

  1. Create a repository on GitHub with code to serve the JSON file
  2. Create an app on Heroku that runs the code in that repository

The code we’re interested in is pretty much straight off the node.js website:

var http = require(‘http’);var json = {
“applinks”: {
“apps”: [],
“details”: [
{
“appID”: “5C79KQUVVH.com.constellational”,
“paths”: [ “*” ]
}
]
}
};
var port = process.env.PORT || 3000;http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type’: ‘application/json’});
res.end(JSON.stringify(json));
}).listen(port);

To get this running on Heroku, we also need an NPM package.json:

{ 
“name”: “constellational-web”,
“version”: “1.0.0”,
“main”: “index.js”,
“scripts”: {
“start”: “node index.js”
}
}

An app.json:

{
“name”: “Constellational”,
“repository”: “https://github.com/constellational/web"
}

And a Procfile:

web: npm start

And that’s it! You’ve made your first web app! Make sure your app on Heroku is connected to your Github repository, and click on “Deploy Branch” at the bottom of the deploy page.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade