You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2023/01/19 03:30:36 UTC

[GitHub] [apisix] githubxubin opened a new issue, #8710: 前后端跨域问题 CORS policy

githubxubin opened a new issue, #8710:
URL: https://github.com/apache/apisix/issues/8710

   ### Description
   
   1.新建路由 开启cors 插件
   `{
     "uri": "/cor/*",
     "name": "test",
     "desc": "test",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "plugins": {
       "cors": {
         "allow_credential": false,
         "allow_headers": "*",
         "allow_methods": "*",
         "allow_origins": "*",
         "disable": false,
         "expose_headers": "*",
         "max_age": 5
       },
       "proxy-rewrite": {
         "regex_uri": [
           "^/cor(/|$)(.*)",
           "/$2"
         ]
       }
     },
     "upstream": {
       "nodes": [
         {
           "host": "192.168.85.66",
           "port": 8001,
           "weight": 1
         }
       ],
       "timeout": {
         "connect": 6,
         "send": 6,
         "read": 6
       },
       "type": "roundrobin",
       "scheme": "http",
       "pass_host": "pass",
       "keepalive_pool": {
         "idle_timeout": 60,
         "requests": 1000,
         "size": 320
       }
     },
     "labels": {
       "API_VERSION": "v1.0"
     },
     "status": 1
   }`
   
   
   2.前后端分离项目,直接调用路由地址,google 浏览器 报跨域错误
   ![image](https://user-images.githubusercontent.com/39228009/213348858-40190bff-719f-4b95-a294-fe7393e95e3a.png)
   
   
   ### Environment
   
   - APISIX version (run `apisix version`):
   - Operating system (run `uname -a`):
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] githubxubin closed issue #8710: 前后端跨域问题 CORS policy

Posted by GitBox <gi...@apache.org>.
githubxubin closed issue #8710: 前后端跨域问题 CORS policy 
URL: https://github.com/apache/apisix/issues/8710


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8710: 前后端跨域问题 CORS policy

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8710:
URL: https://github.com/apache/apisix/issues/8710#issuecomment-1396469247

   If still have a problem, you can set `Access-Control-Allow-Origin: http://domain.com`. Change  domain.com to your domain


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] githubxubin commented on issue #8710: 前后端跨域问题 CORS policy

Posted by GitBox <gi...@apache.org>.
githubxubin commented on issue #8710:
URL: https://github.com/apache/apisix/issues/8710#issuecomment-1396470001

   > If still have a problem, you can set `Access-Control-Allow-Origin: http://domain.com`. Change domain.com to your domain
   
   okey ~  thanks it is ok


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8710: 前后端跨域问题 CORS policy

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8710:
URL: https://github.com/apache/apisix/issues/8710#issuecomment-1396483717

   You can close this issue now :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8710: 前后端跨域问题 CORS policy

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8710:
URL: https://github.com/apache/apisix/issues/8710#issuecomment-1396397833

   Maybe you can set allow credentials to true.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org