I feel like pulling my hair out; this is either super simple and i'm having brain freeze or it is not that simple.

What I want

I am trying to unshorten a shortened URL using firebase, when a user goes to:

myapp.firebaseappurl.com/url/SHORTENEDLINK

SO wont let me add a shortened URL

I would like the output to be:

{ "url": "https://stackoverflow.com/questions/45420989/sphinx-search-how-to-use-an-empty-before-match-and-after-match" }

What I have tried

firebase.json file:

{ "hosting": { "public": "public", "rewrites": [ { "source": "/url/:item", "destination": "/url/:item" } ] } }

index.js file:

const functions = require('firebase-functions'); exports.url = functions.https.onRequest((requested, response) => { var uri = requested.url; request({ uri: uri, followRedirect: true }, function(err, httpResponse) { if (err) { return console.error(err); } response.send(httpResponse.headers.location || uri); } ); });

Result

When I go to myapp.firebaseappurl.com/url/SHORTENEDLINK I get the following: