如何在 lua 中修改 ngx.location.capture 请求方法?

我在文档中看到了下面的修改方式:

res = ngx.location.capture(
     '/foo/bar',
     { method = ngx.HTTP_POST, body = 'hello, world' }
 )

于是我按照以下方式更改我的方法:

res = ngx.location.capture("/api/auth-check", {
    method = ngx.HTTP_POST,
    args = {
       checkToken = field
    }
})

但是当我执行请求时,发现它不起作用。当父请求方法为GET时,capture 方法为GET,当父请求为POST时,capture 也是POST,我不知道为什么在我的代码中没有改变。

我在 ngxin location 中使用 access_by_lua 上下文。

我不知道是否缺少某些配置?

原文链接 https://stackoverflow.com/questions/70505884

点赞