close
The Wayback Machine - https://web.archive.org/web/20211018205243/https://github.com/apache/apisix/issues/5165
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: plugin wolf-rbac /apisix/plugin/wolf-rbac/login resturn header is text/plain , cors error #5165

Open
laokan opened this issue Sep 30, 2021 · 9 comments

Comments

@laokan
Copy link

@laokan laokan commented Sep 30, 2021

Issue description

  1. the pluginx wolf-rbac 's login url /apisix/plugin/wolf-rbac/login return the json but header give the content-type is text/plain, when the browsr crossdomain post then show the cors error, please change the plugin login post give the Content-type to application/json

  2. The wolf-rabc 's login uri /apisix/plugin/wolf-rbac/login will lose the cors plugin add the Header

Environment

  • apisix version (cmd: apisix version):
  • OS (cmd: uname -a):
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API):
  • apisix-dashboard version, if have:
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version):

Steps to reproduce

post /apisix/plugin/wolf-rbac/login show the response header

Actual result

text/plain

Error log

the browser given the cors error

Expected result

No response

@spacewander
Copy link
Member

@spacewander spacewander commented Oct 8, 2021

You can add cors as a plugin interceptor:

local interceptors = {

PR is welcome!

@laokan
Copy link
Author

@laokan laokan commented Oct 8, 2021

add header_modify interceptors ?

@spacewander
Copy link
Member

@spacewander spacewander commented Oct 8, 2021

cors interceptors. We can reuse the code.

@spacewander
Copy link
Member

@spacewander spacewander commented Oct 8, 2021

My bad! It is not about providing cors to wolf-rbac login. We just need to fix the login handler with core.response.set_header("Content-Type", "application/json")

@laokan
Copy link
Author

@laokan laokan commented Oct 8, 2021

after at /usr/local/apisix/apisix/plugins/wolf-rabc.lua add core.response.set_header("Content-Type", "application/json"
the response give the right header but The browser given the CORS error

@laokan
Copy link
Author

@laokan laokan commented Oct 8, 2021

diff The work and not work I found
not work:
HTTP/1.1 200 OK Date: Fri, 08 Oct 2021 05:16:50 GMT Content-Type: application/json Transfer-Encoding: chunked Connection: keep-alive Server: APISIX/2.5
work:
HTTP/1.1 200 OK Date: Fri, 08 Oct 2021 05:19:04 GMT Content-Type: text/plain; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Server: APISIX/2.5 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: * Access-Control-Max-Age: 5 Access-Control-Expose-Headers: * Access-Control-Allow-Headers: *

when rabc-plugin register route ‘apisix/plugin/wolf-rbac/login’ then the Globalroute of cors plugin lose efficacy

@spacewander
Copy link
Member

@spacewander spacewander commented Oct 8, 2021

So we still need cors interceptors.

@laokan
Copy link
Author

@laokan laokan commented Oct 8, 2021

yes, add cors interceptors ,the cors ‘s conf should use the route cors plugin config

@zhendongcmss
Copy link
Contributor

@zhendongcmss zhendongcmss commented Oct 15, 2021

yes, add cors interceptors ,the cors ‘s conf should use the route cors plugin config

Hi @laokan and @spacewander sorry , I don't get your idea. Can you give more details. I want to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants