【问题标题】:Fastify redirect to external URLFastify 重定向到外部 URL
【发布时间】:2021-08-09 12:06:01
【问题描述】:

使用fastify 库我想被重定向到一个网页。 查看文档中的所有示例,似乎它只涵盖了路由到路由的重定向。

Link to redirect docs

fastify.post('/v1/launch', async (req, res) => {
  response.redirect('/empty-cart');
});

上面的代码在尝试查找该路由时导致 404 错误。

但是如何将其重定向到外部页面?谢谢!

更新: 尝试重定向到https://my-domain.com/empty-cart

出现ERR_NAME_NOT_RESOLVED 错误

【问题讨论】:

  • response.redirect('https://example.com');
  • @0stone0 问题已更新。还是不行
  • 如果您在浏览器中输入my-domain.com/empty-cart,您会得到什么或 404?
  • @Frazer 看上面更新
  • 我的意思是如果你直接访问 https : //my-domain.com/empty-cart,而不是通过重定向。

标签: javascript node.js fastify


【解决方案1】:

请尝试

response.redirect('https://stackoverflow.com/')

【讨论】:

    猜你喜欢
    • 2017-12-11
    • 2012-01-10
    • 2012-08-02
    • 1970-01-01
    • 2019-04-03
    • 2019-10-23
    • 2015-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多