有点,转换 localhost URL 会导致错误 INVALID_ARG_LONG_URL,这是预期的吗?

问题描述 投票:0回答:2

我正在使用 npmjs 的 bitly 包在开发环境中测试 bitly,当我运行

bitly.shorten(link)
时,我收到以下错误消息:

{
  "message": "INVALID_ARG_LONG_URL",
  "resource": "bitlinks",
  "description": "The value provided is invalid.",
  "errors": [
    {
      "field": "long_url",
      "error_code": "invalid"
    }
  ]
}

缩短的网址是

http://localhost:3000/file/cto/pdf/en/2020-11-19/Presentation-Customer-AREVA-Hydrolic.pdf

是否会禁止

localhost
链接的转换?

我尝试添加

https
而不是
http
,但这不起作用,我检查了他们的文档,没有看到任何限制。

我认为 bitly 是为了缩短长网址而设计的。

这是否预计会失败,或者由于 URL 太长而在生产环境中也会失败?

node.js web url url-shortener bitly
2个回答
8
投票

使用

http://127.0.0.1
而不是
localhost
。这对我有用。


0
投票

将 localhost 替换为您的 IP。有点不招待本地主机

在您的情况下,请设置您的网址: http://10.10.10.10:3000/file/cto/pdf/en/2020-11-19/Presentation-Customer-AREVA-Hydrolic.pdf

© www.soinside.com 2019 - 2024. All rights reserved.