我想把头发拉出来; 这是超级简单的,我有脑冻结或它不是那么简单.
当用户访问时,我试图使用firebase取消缩短缩短的URL:所以
myapp.firebaseappurl.com/url/SHORTENEDLINK
我不会让我添加缩短的URL
我希望输出为:
{
"url": "https://stackoverflow.com/questions/45420989/sphinx-search-how-to-use-an-empty-before-match-and-after-match"
}
Run Code Online (Sandbox Code Playgroud)
firebase.json 文件:
{
"hosting": {
"public": "public",
"rewrites": [ {
"source": "/url/:item",
"destination": "/url/:item"
} ]
}
}
Run Code Online (Sandbox Code Playgroud)
index.js 文件:
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);
}
);
});
Run Code Online (Sandbox Code Playgroud)
当我去的时候,myapp.firebaseappurl.com/url/SHORTENEDLINK我得到以下内容:
Error: could not handle the request
Run Code Online (Sandbox Code Playgroud) url-shortener node.js firebase firebase-hosting google-cloud-functions