Github user iilyak commented on a diff in the pull request:

    https://github.com/apache/couchdb-chttpd/pull/101#discussion_r53062299
  
    --- Diff: src/chttpd_cors.erl ---
    @@ -306,6 +316,35 @@ get_cors_config(#httpd{cors_config = undefined}) ->
     get_cors_config(#httpd{cors_config = Config}) ->
         Config.
     
    +cors_config(Host, Key, Default) ->
    +    config:get(cors_section(Host), Key,
    +                     config:get("cors", Key, Default)).
    +
    +cors_section(Host0) ->
    +    {Host, _Port} = split_host_port(Host0),
    --- End diff --
    
    Existent `split_host_port` function would work even in the absence of 
schema. [The "`Origins must include the scheme: http://example.com`"; 
comment](https://github.com/cloudant/couchdb/blob/master/rel/overlay/etc/default.ini#L115)
 comment is related to `origins` key within `[cors:http://example.com]` 
section. Below is the config I used for testing:
    ```
    [chttpd]
    enable_cors = true
    
    [cors]
    credentials = true
    methods = GET,HEAD,POST,PUT,DELETE,OPTIONS
    headers = accept,authorization,content-type
    
    [cors:http://partner.com]
    methods = GET,DELETE
    headers = 
Custom_header1,custom_header2,accept,authorization,content-type,x-couchdb-csrf
    exposed_headers = x-couchdb-Secret
    origins = http://restricted.dev:8000
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to