我正在寻找修改请求标头并在 Lua 中重定向它,我已经尝试过
ngx.redirect("/")
Run Code Online (Sandbox Code Playgroud)
和
ngx.exec("/")
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
attempt to call ngx.redirect after sending out the headers
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法来添加标头值并将其重定向到 Lua 中的其他位置?在文档中我没有找到任何合适的指令,有没有一种方法可以在仍然使用content_by_lua_file的同时完成类似的操作?
我正在使用 openresty。