【问题标题】:How to redirect to external URL with post parameters?如何使用 post 参数重定向到外部 URL?
【发布时间】:2019-05-02 23:35:50
【问题描述】:

当用户到达我的终点时,它必须被重定向到带有 url 编码表单参数的外部 URL。

终点

https://example.com

表单参数

名称:测试, 编号:123456

这是我现在在 Express 中尝试的。它被重定向到 URL,但我不知道如何添加参数。

app.get('/', (req, res) => res.redirect(302,'https://example.com')) 

【问题讨论】:

    标签: javascript node.js express url-redirection http-redirect


    【解决方案1】:

    您不能将参数作为 POT 请求进行重定向。

    你有两个选择:

    1. 为查询字符串添加参数:

      示例:https://example.com/?ParameterOne='xxx'

    2. 通过你使用的视图引擎使用res.render,带参数并使用以下内容。

      示例:res.render('index', {parameterOne: xxx})

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 2016-03-27
      • 1970-01-01
      • 2012-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多