简体   繁体   English

如何使用发布参数重定向到外部URL?

[英]How to redirect to external URL with post parameters?

When user hits my end point it has to be redirected to an external URL with url encoded form parameters. 当用户到达我的终点时,必须将其重定向到带有url编码形式参数的外部URL。

End point 终点

https://example.com https://example.com

Form parameters 表单参数

name:testing, id: 123456 名称:测试ID:123456

This is what I tried for now in Express. 这就是我现在在Express中尝试过的。 It gets redirected to the URL but I don't know how to add parameters. 它被重定向到URL,但我不知道如何添加参数。

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

You can't redirect with parameters as a POT request. 您不能将参数重定向为POT请求。

You have 2 options: 您有2个选择:

  1. add parameters to query string: 在查询字符串中添加参数:

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

  2. use res.render , with parameters and use the following through the view engine u use. 使用带有参数的res.render ,并通过您使用的视图引擎使用以下内容。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM