{"action":"created","issue":{"url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/1257","repository_url":"https://api.github.com/repos/openresty/lua-nginx-module","labels_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/1257/labels{/name}","comments_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/1257/comments","events_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/1257/events","html_url":"https://github.com/openresty/lua-nginx-module/issues/1257","id":296257910,"number":1257,"title":"add_header fail when call function (ngx.print(_M.subscriber()) )   in  Lua","user":{"login":"VuDn5","id":36143595,"avatar_url":"https://avatars1.githubusercontent.com/u/36143595?v=4","gravatar_id":"","url":"https://api.github.com/users/VuDn5","html_url":"https://github.com/VuDn5","followers_url":"https://api.github.com/users/VuDn5/followers","following_url":"https://api.github.com/users/VuDn5/following{/other_user}","gists_url":"https://api.github.com/users/VuDn5/gists{/gist_id}","starred_url":"https://api.github.com/users/VuDn5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VuDn5/subscriptions","organizations_url":"https://api.github.com/users/VuDn5/orgs","repos_url":"https://api.github.com/users/VuDn5/repos","events_url":"https://api.github.com/users/VuDn5/events{/privacy}","received_events_url":"https://api.github.com/users/VuDn5/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-12T03:28:15Z","updated_at":"2018-02-12T16:50:40Z","closed_at":null,"author_association":"NONE","body":"**Hi everybody!  \r\nI'm Vu and i come from Viet Nam.  i have a API like that http://\"MyIP\"/subscriber/check-forget-passwd.  Client cannot call API and error is : cross domain, i fix it by**\r\n`add_header 'Access-Control-Allow-Origin' '*';`\r\n **That My configure** \r\n`        add_header 'Access-Control-Allow-Origin' '*';\r\n        add_header 'Access-Control-Allow-Credentials' 'true';\r\n        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';\r\n        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';\r\n                client_max_body_size 50k;\r\n                client_body_buffer_size 50k;\r\n                default_type 'text/plain;charset=utf-8';\r\n                content_by_lua '\r\n                        ngx.print(_M.subscriber())\r\n                        ngx.print(\"adf\")\r\n                        ngx.req.set_header(\"Access-Control-Allow-Origin\", \"*\")\r\n                        ngx.req.set_header(\"ContentType\", \"application/json\")\r\n                        return\r\n                ';` \r\n  **it's cannot response any\" response header\" but if i remove the line** \r\n`ngx.print(_M.subscriber())\r\n_M is a nomarl function( or class\u0010 or may be like class) that i write by Lua`\r\neverything back is ok, there are my output: \r\n`server:\r\nopenresty/1.11.2.1\r\ndate:\r\nMon, 12 Feb 2018 03:25:33 GMT\r\ncontent-type:\r\ntext/plain;charset=utf-8\r\ntransfer-encoding:\r\nchunked\r\nconnection:\r\nkeep-alive\r\naccess-control-allow-origin:\r\n*; *\r\naccess-control-allow-credentials:\r\ntrue; true\r\naccess-control-allow-methods:\r\nGET, POST, OPTIONS; GET, POST, OPTIONS\r\naccess-control-allow-headers:\r\nDNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type; DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type`\r\n\r\n**This is Bug or my config errror and how can i  fix it? \r\nThank for read!\r\nVu**"},"comment":{"url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/comments/364985717","html_url":"https://github.com/openresty/lua-nginx-module/issues/1257#issuecomment-364985717","issue_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/1257","id":364985717,"user":{"login":"VuDn5","id":36143595,"avatar_url":"https://avatars1.githubusercontent.com/u/36143595?v=4","gravatar_id":"","url":"https://api.github.com/users/VuDn5","html_url":"https://github.com/VuDn5","followers_url":"https://api.github.com/users/VuDn5/followers","following_url":"https://api.github.com/users/VuDn5/following{/other_user}","gists_url":"https://api.github.com/users/VuDn5/gists{/gist_id}","starred_url":"https://api.github.com/users/VuDn5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VuDn5/subscriptions","organizations_url":"https://api.github.com/users/VuDn5/orgs","repos_url":"https://api.github.com/users/VuDn5/repos","events_url":"https://api.github.com/users/VuDn5/events{/privacy}","received_events_url":"https://api.github.com/users/VuDn5/received_events","type":"User","site_admin":false},"created_at":"2018-02-12T16:50:40Z","updated_at":"2018-02-12T16:50:40Z","author_association":"NONE","body":"Thanks @spacewander \u0010!  i have a solution for that!    i use \r\n`more_set_headers 'Access-Control-Allow-Origin: *' ;`     to fix that problem and successed, thanks for you help!~ "}}
{"actor":{"display_login":"VuDn5"}}