{"action":"created","issue":{"url":"https://api.github.com/repos/RasaHQ/rasa_nlu/issues/1420","repository_url":"https://api.github.com/repos/RasaHQ/rasa_nlu","labels_url":"https://api.github.com/repos/RasaHQ/rasa_nlu/issues/1420/labels{/name}","comments_url":"https://api.github.com/repos/RasaHQ/rasa_nlu/issues/1420/comments","events_url":"https://api.github.com/repos/RasaHQ/rasa_nlu/issues/1420/events","html_url":"https://github.com/RasaHQ/rasa_nlu/issues/1420","id":364382255,"node_id":"MDU6SXNzdWUzNjQzODIyNTU=","number":1420,"title":"Current CORS options of Rasa NLU HTTP server are too limited","user":{"login":"neo-alex","id":26087829,"node_id":"MDQ6VXNlcjI2MDg3ODI5","avatar_url":"https://avatars0.githubusercontent.com/u/26087829?v=4","gravatar_id":"","url":"https://api.github.com/users/neo-alex","html_url":"https://github.com/neo-alex","followers_url":"https://api.github.com/users/neo-alex/followers","following_url":"https://api.github.com/users/neo-alex/following{/other_user}","gists_url":"https://api.github.com/users/neo-alex/gists{/gist_id}","starred_url":"https://api.github.com/users/neo-alex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neo-alex/subscriptions","organizations_url":"https://api.github.com/users/neo-alex/orgs","repos_url":"https://api.github.com/users/neo-alex/repos","events_url":"https://api.github.com/users/neo-alex/events{/privacy}","received_events_url":"https://api.github.com/users/neo-alex/received_events","type":"User","site_admin":false},"labels":[{"id":461549562,"node_id":"MDU6TGFiZWw0NjE1NDk1NjI=","url":"https://api.github.com/repos/RasaHQ/rasa_nlu/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-27T09:24:55Z","updated_at":"2018-12-24T07:56:57Z","closed_at":null,"author_association":"NONE","body":"<!-- If you don't know your Rasa NLU version, here is some help: https://goo.gl/g9QQg2. If you are creating a feature request, feel free to remove all the system information stuff. --> \r\n\r\n**Rasa NLU version**: 0.13.4\r\n\r\n**Operating system** (windows, osx, ...): Windows\r\n\r\n**Content of model configuration file**:\r\n```yml\r\nlanguage: \"en\"\r\n\r\npipeline: \"spacy_sklearn\"\r\n```\r\n\r\n**Issue**:\r\nWhen calling an endpoint like /train of Rasa NLU HTTP server (server.py) from a browser such as Chrome (e.g. a web app), an exception is raised even when adding the option --cors *. Indeed, Chrome automatically sends an OPTIONS request first (before the actual POST one) to check what is allowed by the server and currently 'Content-Type' is not declared as an allowed header. In particular, this makes it impossible to use the /train endpoint which requires 'Content-Type' to be set to 'application/x-yml'.\r\n\r\nAdding following lines (commented with # ADDED) in server.py inside \"check_cors\" solves the issue:\r\n\r\n```python\r\n            if '*' in self.cors_origins:\r\n                request.setHeader('Access-Control-Allow-Origin', '*')\r\n                request.setHeader('Access-Control-Allow-Headers', 'Content-Type')  # ADDED\r\n                request.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')  # ADDED\r\n            elif origin in self.cors_origins:\r\n                request.setHeader('Access-Control-Allow-Origin', origin)\r\n                request.setHeader('Access-Control-Allow-Headers', 'Content-Type')  # ADDED\r\n                request.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')  # ADDED\r\n```\r\n\r\nCould you please consider it? Thanks!\r\n"},"comment":{"url":"https://api.github.com/repos/RasaHQ/rasa_nlu/issues/comments/449699286","html_url":"https://github.com/RasaHQ/rasa_nlu/issues/1420#issuecomment-449699286","issue_url":"https://api.github.com/repos/RasaHQ/rasa_nlu/issues/1420","id":449699286,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTY5OTI4Ng==","user":{"login":"abhishekchotaliya","id":10126210,"node_id":"MDQ6VXNlcjEwMTI2MjEw","avatar_url":"https://avatars0.githubusercontent.com/u/10126210?v=4","gravatar_id":"","url":"https://api.github.com/users/abhishekchotaliya","html_url":"https://github.com/abhishekchotaliya","followers_url":"https://api.github.com/users/abhishekchotaliya/followers","following_url":"https://api.github.com/users/abhishekchotaliya/following{/other_user}","gists_url":"https://api.github.com/users/abhishekchotaliya/gists{/gist_id}","starred_url":"https://api.github.com/users/abhishekchotaliya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhishekchotaliya/subscriptions","organizations_url":"https://api.github.com/users/abhishekchotaliya/orgs","repos_url":"https://api.github.com/users/abhishekchotaliya/repos","events_url":"https://api.github.com/users/abhishekchotaliya/events{/privacy}","received_events_url":"https://api.github.com/users/abhishekchotaliya/received_events","type":"User","site_admin":false},"created_at":"2018-12-24T07:56:57Z","updated_at":"2018-12-24T07:56:57Z","author_association":"NONE","body":"> **Rasa NLU version**: 0.13.4\r\n> \r\n> **Operating system** (windows, osx, ...): Windows\r\n> \r\n> **Content of model configuration file**:\r\n> \r\n> ```yaml\r\n> language: \"en\"\r\n> \r\n> pipeline: \"spacy_sklearn\"\r\n> ```\r\n> \r\n> **Issue**:\r\n> When calling an endpoint like /train of Rasa NLU HTTP server (server.py) from a browser such as Chrome (e.g. a web app), an exception is raised even when adding the option --cors *. Indeed, Chrome automatically sends an OPTIONS request first (before the actual POST one) to check what is allowed by the server and currently 'Content-Type' is not declared as an allowed header. In particular, this makes it impossible to use the /train endpoint which requires 'Content-Type' to be set to 'application/x-yml'.\r\n> \r\n> Adding following lines (commented with # ADDED) in server.py inside \"check_cors\" solves the issue:\r\n> \r\n> ```python\r\n>             if '*' in self.cors_origins:\r\n>                 request.setHeader('Access-Control-Allow-Origin', '*')\r\n>                 request.setHeader('Access-Control-Allow-Headers', 'Content-Type')  # ADDED\r\n>                 request.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')  # ADDED\r\n>             elif origin in self.cors_origins:\r\n>                 request.setHeader('Access-Control-Allow-Origin', origin)\r\n>                 request.setHeader('Access-Control-Allow-Headers', 'Content-Type')  # ADDED\r\n>                 request.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')  # ADDED\r\n> ```\r\n> \r\n> Could you please consider it? Thanks!\r\n\r\nThe above request is very important for the developers who wants to integrate rasa nlu in their application.\r\n\r\nEven I am also facing the issue and my development work is stuck because of it.\r\n\r\n**One important point though:**\r\n@neo-alex \r\nEven after adding the above lines in server.py, it is failing.\r\nNow, the options request is 200, but the actual post `/parse` api request is **404** Not Found\r\n\r\ncommand to run the server:\r\n`python -m rasa_nlu.server -c config.yaml  --pre_load model_1 --path models/nlu/ --cors *`"}}
{"actor":{"display_login":"abhishekchotaliya"}}