<legend id='DYrpa'><style id='DYrpa'><dir id='DYrpa'><q id='DYrpa'></q></dir></style></legend>
      <bdo id='DYrpa'></bdo><ul id='DYrpa'></ul>

    <i id='DYrpa'><tr id='DYrpa'><dt id='DYrpa'><q id='DYrpa'><span id='DYrpa'><b id='DYrpa'><form id='DYrpa'><ins id='DYrpa'></ins><ul id='DYrpa'></ul><sub id='DYrpa'></sub></form><legend id='DYrpa'></legend><bdo id='DYrpa'><pre id='DYrpa'><center id='DYrpa'></center></pre></bdo></b><th id='DYrpa'></th></span></q></dt></tr></i><div id='DYrpa'><tfoot id='DYrpa'></tfoot><dl id='DYrpa'><fieldset id='DYrpa'></fieldset></dl></div>
    <tfoot id='DYrpa'></tfoot>

      1. <small id='DYrpa'></small><noframes id='DYrpa'>

        Azure Functions 重定向标头

        时间:2023-08-02

              <bdo id='KjJu7'></bdo><ul id='KjJu7'></ul>
                <tbody id='KjJu7'></tbody>

                <legend id='KjJu7'><style id='KjJu7'><dir id='KjJu7'><q id='KjJu7'></q></dir></style></legend>

                <small id='KjJu7'></small><noframes id='KjJu7'>

              1. <i id='KjJu7'><tr id='KjJu7'><dt id='KjJu7'><q id='KjJu7'><span id='KjJu7'><b id='KjJu7'><form id='KjJu7'><ins id='KjJu7'></ins><ul id='KjJu7'></ul><sub id='KjJu7'></sub></form><legend id='KjJu7'></legend><bdo id='KjJu7'><pre id='KjJu7'><center id='KjJu7'></center></pre></bdo></b><th id='KjJu7'></th></span></q></dt></tr></i><div id='KjJu7'><tfoot id='KjJu7'></tfoot><dl id='KjJu7'><fieldset id='KjJu7'></fieldset></dl></div>
                <tfoot id='KjJu7'></tfoot>

                  本文介绍了Azure Functions 重定向标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望我的一个 Azure Functions 执行 HTTP 重定向.

                  I want one of my Azure Functions to do an HTTP Redirection.

                  这是函数的当前代码:

                  module.exports = context => {
                    context.res.status(302)
                    context.res.header('Location', 'https://www.stackoverflow.com')
                    context.done()
                  }
                  

                  但它不起作用.

                  从 Postman 发送的请求显示响应有:

                  A request sent from Postman shows the response has:

                  • 状态:200
                  • 位置未设置
                  • Status: 200
                  • Location not set

                  这是正确的代码吗?还是 Azure Functions 根本不允许?

                  Is this correct code? Or is it simply not allowed by Azure Functions?

                  推荐答案

                  上面的代码确实有效,除非您将绑定名称设置为 $return,这就是我假设您现在拥有的(您可以在集成标签)

                  The code above actually does work, unless you have your binding name set to $return, which is what I assume you have now (you can check in the integrate tab)

                  以下任一选项也可以满足您的需求

                  Either of the following options will also do what you're looking for

                  假设 $return 在绑定配置中:

                  Assuming $return in the binding configuration:

                  module.exports = function (context, req) {
                  var res = { status: 302, headers: { "location": "https://www.stackoverflow.com" }, body: null};
                  context.done(null, res);
                  };
                  

                  或者使用express style"API(在绑定配置中不使用$return):

                  Or using the "express style" API (not using $return in the binding configuration):

                  module.exports = function (context, req) {
                  context.res.status(302)
                              .set('location','https://www.stackoverflow.com')
                              .send();
                  };
                  

                  这篇关于Azure Functions 重定向标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:“异步"Azure Function App 未按预期等待 下一篇:Azure Functions - 值不能为空.(参数“连接字符串")

                  相关文章

                • <i id='u7nlj'><tr id='u7nlj'><dt id='u7nlj'><q id='u7nlj'><span id='u7nlj'><b id='u7nlj'><form id='u7nlj'><ins id='u7nlj'></ins><ul id='u7nlj'></ul><sub id='u7nlj'></sub></form><legend id='u7nlj'></legend><bdo id='u7nlj'><pre id='u7nlj'><center id='u7nlj'></center></pre></bdo></b><th id='u7nlj'></th></span></q></dt></tr></i><div id='u7nlj'><tfoot id='u7nlj'></tfoot><dl id='u7nlj'><fieldset id='u7nlj'></fieldset></dl></div>

                    <small id='u7nlj'></small><noframes id='u7nlj'>

                    <legend id='u7nlj'><style id='u7nlj'><dir id='u7nlj'><q id='u7nlj'></q></dir></style></legend>

                  1. <tfoot id='u7nlj'></tfoot>

                      • <bdo id='u7nlj'></bdo><ul id='u7nlj'></ul>