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 2021/06/03 14:58:53 UTC

[GitHub] [apisix] starsz commented on issue #4358: request help: apisix cannot use CORS plug-in after upgrading from 2.0 to 2.5 and partial route failure

starsz commented on issue #4358:
URL: https://github.com/apache/apisix/issues/4358#issuecomment-853935998


   > I have tried use the cors with apisix admin-api, but got error:
   > 
   > ```shell
   > curl http://127.0.0.1:9080/apisix/admin/routes/2 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
   > {
   >     "uri": "/*",
   >     "hosts": ["foo.com"],
   >     "upstream": {
   >         "type": "roundrobin",
   >         "nodes": {
   >             "httpbin.org": 1
   >         }
   >     },
   >     "plugins": {
   >         "cors": {
   >          "allow_credential": true,
   >          "allow_headers": "*",
   >          "allow_methods": "*",
   >          "allow_origins": "*",
   >          "expose_headers": "*",
   >          "max_age": 5
   >         }
   >     }
   > }'
   > ```
   > 
   > Got error as below
   > 
   > ```shell
   > {"error_msg":"failed to check the configuration of plugin cors err: you can not set '*' for other option when 'allow_credential' is true"}
   > ```
   > 
   > It seems that when the cors plug-in is created through the dashboard, there is no shcema verification about this.
   > And APISIX will get error , when watch the change about cors plugin from etcd.
   > 
   > It is a bug in dashboard.
   > 
   > cc @nic-chen @starsz
   
   In fact, the dashboard had schema verification about this :
   you can referer: 
   
   https://github.com/apache/apisix-dashboard/blob/9850df28b9539713566849069ba093b6be7c3be7/api/conf/schema.json#L2458
   
   The error:
   ```
   {"error_msg":"failed to check the configuration of plugin cors err: you can not set '*' for other option when 'allow_credential' is true"}
   ```
   is validate by lua code.This can't be validated in apisix-dashboard.
   
   you can referer to:
   https://github.com/apache/apisix/blob/c61261af8d19557b77535c9c745f4f8182bb63b2/apisix/plugins/cors.lua#L134-L137
   


-- 
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.

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