liuxiran opened a new pull request #1855:
URL: https://github.com/apache/apisix-dashboard/pull/1855


   Please answer these questions before submitting a pull request, **or your PR 
will get closed**.
   
   **Why submit this pull request?**
   
   - [X] Bugfix
   - [ ] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   **What changes will this PR take into?**
   
   when I submitted default cors plugin configure in form mode, a validation 
error occured:
   
   ![2021-05-07 
13-40-50屏幕截图](https://user-images.githubusercontent.com/2561857/117403225-6d33b000-af3a-11eb-99f2-6deb59cd432e.png)
   
   the error shows that `allow_origins_by_regex` should have at least 1 
character.
   
   *  Reason
   
   schema of `cors` plugin:
   ```json
   {
       "properties": {
           ...
        "allow_origins_by_regex": {
            "description": "you can use regex to allow specific origins when no 
credentials,for example use [.*\\.test.com] to allow a.test.com and b.test.com",
            "items": {
                 "maxLength": 4096,
                 "minLength": 1,
                 "type": "string"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": true
        },
       },
      "type": "object"
   }
   ```
   shows that `allow_origins_by_regex` is not a required item, but when it 
configured, it should be at least 1 character.
   
   the default post data is:
   ```json
   {
       "allow_credential": false
       "allow_headers": "*"
       "allow_methods": ["*"]
       "allow_origins": "*"
       "allow_origins_by_regex": [""]
       "expose_headers": "*"
       "max_age": 5
   }
   ```
   the mistake is ` "allow_origins_by_regex": [""]`, why the value is [""]? In 
order to make UI better to use, we set default `allow_origins_by_regex` empty 
to have one input box in the page.
   
   * How to fix
   omit `allow_origins_by_regex` when it is not configured
   
   **Checklist:**
   
   - [X] Did you explain what problem does this PR solve? Or what new features 
have been added?
   - [ ] Have you added corresponding test cases?
   - [ ] Have you modified the corresponding document?
   - [X] Is this PR backward compatible? If it is not backward compatible, 
please discuss on the mailing list first
   


-- 
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:
[email protected]


Reply via email to