Firebase short URLs not redirecting

半城伤御伤魂 提交于 2021-01-28 18:15:45

问题


I created a Google Sheet that uses a Google Script to generate short URLs via Firebase API.

This is the code in the Google Script

function URLShortener(longURL) {
  var body = {
    "dynamicLinkInfo": {
      "domainUriPrefix": "https://go.example.com",
      "link" : longURL
    },
    "suffix": {
      "option": "SHORT"
    }
  };
  var key = 'xxxxxxx'
  var url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=" + key;
  var options = {
    'method': 'POST',
    "contentType": "application/json",
    'payload': JSON.stringify(body),
  };
  var response = UrlFetchApp.fetch(url, options);
  var json = response.getContentText();
  var data = JSON.parse(json);
  var obj = data["shortLink"];
  return obj;
  Logger.log(obj)
}

The script works and it generates URLs similar to https://go.example.com/Xdka but these link redirect to https://example.com/Xdka instead of the actual URL that is sent, e.g. https://example.com/final_url.

If I try to generate these short links from the Firebase dashboard the same happens.

Did I misunderstand how these short URLs work or am I missing something?

来源:https://stackoverflow.com/questions/63604093/firebase-short-urls-not-redirecting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!