mscb402 commented on issue #8399: URL: https://github.com/apache/apisix/issues/8399#issuecomment-1327096392
> > I try it on my local env. I know what happened. This is because the cors plugin will match `allow_origins` first, if `allow_origins` does not match then it will try to match it with regex using `allow_origins_by_regex`. > > Therefore when `allow_origins` set as `*`, any URL will matched, so that `allow_origins_by_regex` will not match again. > > So, the right config is below. You can change `http://example.com` to any URL you are NOT using like `http://baidu.com` or `http://xxx.com`. Just make `allow_origins` not match. > > ```json > > { > > "allow_credential": false, > > "allow_headers": "*", > > "allow_methods": "*", > > "allow_origins": "http://example.com", > > "allow_origins_by_regex": [ > > ".*\\.test\\.com", > > "test\\.com" > > ], > > "expose_headers": "*", > > "max_age": 5 > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > > or > > ```json > > { > > "allow_credential": false, > > "allow_headers": "*", > > "allow_methods": "*", > > "allow_origins": "http://test.com", > > "allow_origins_by_regex": [], > > "expose_headers": "*", > > "max_age": 5 > > } > > ``` > > 谢谢,确实是这个原因,问题已经解决了。 > > 另外,apisix-dashboard 上的帮助说明有问题,容易误导用户。可以修改一下  Ok, I'm opening a new issue for this. Thanks for your support for Apisix -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
