Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cors_origins is empty #1880

Closed
gadapa-rakesh opened this issue Dec 20, 2017 · 2 comments
Closed

cors_origins is empty #1880

gadapa-rakesh opened this issue Dec 20, 2017 · 2 comments

Comments

@gadapa-rakesh
Copy link

Rasa Core version: 0.7.9

Python version: 3.6

Operating system (windows, osx, ...): OSX

Issue:
came across CORS issue while trying to run the rasa_core.server.
Then changed the config file to include the cors_origins
Here is how my config.json looks like

{
    "pipeline": [
        "nlp_spacy",
        "tokenizer_spacy",
        "intent_featurizer_spacy",
        "intent_classifier_sklearn",
        "ner_crf",
        "ner_synonyms"
    ],
    "path": "./models",
    "project": "nlu",
    "data": "./data/training_data.json",
    "cors_origins" : ["*"]
}

Tried to debug the code under rasa_nlu (server.py) and found that the configuration is empty

def check_cors(f):
    """Wraps a request handler with CORS headers checking."""

    @wraps(f)
    def decorated(*args, **kwargs):
        self = args[0]
        request = args[1]
        origin = request.getHeader('Origin')
        logger.debug("-------------------------")
        logger.debug(self.config)
        logger.debug("-------------------------")
        if origin:
            if '*' in self.config['cors_origins']:
                request.setHeader('Access-Control-Allow-Origin', '*')
            elif origin in self.config['cors_origins']:
                request.setHeader('Access-Control-Allow-Origin', origin)
            else:
                request.setResponseCode(403)
                return 'forbidden'

        if request.method.decode('utf-8', 'strict') == 'OPTIONS':
            return ''  # if this is an options call we skip running `f`
        else:
            return f(*args, **kwargs)

    return decorated

logs:

$ python -m rasa_core.server -d models/dialogue/ -u models/nlu/current/ -o out.log
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''.  Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied.  Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification.  Many valid certificate/hostname mappings may be rejected.
Using TensorFlow backend.
WARNING:py.warnings:/Users/e133300/anaconda3/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)

2017-12-20 11:51:31.910419: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
INFO:rasa_nlu.components:Added 'nlp_spacy' to component cache. Key 'nlp_spacy-en'.
INFO:__main__:Started http server on port 5005
2017-12-20 11:51:34-0500 [-] Log opened.
2017-12-20 11:51:34-0500 [-] Site starting on 5005
2017-12-20 11:51:34-0500 [-] Starting factory <twisted.web.server.Site object at 0x12baa5e48>
DEBUG:rasa_nlu.server:-------------------------
DEBUG:rasa_nlu.server:{'cors_origins': []}
DEBUG:rasa_nlu.server:-------------------------
2017-12-20 11:51:42-0500 [-] "127.0.0.1" - - [20/Dec/2017:16:51:41 +0000] "POST /conversations/12345/parse HTTP/1.1" 403 9 "http://localhost:8100/" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1"
2017-12-20 11:52:42-0500 [-] Timing out client: IPv4Address(TCP, '127.0.0.1', 52956)

Therefore response to my request was always 403.

Kindly let me know if I am missing anything. Thank you in advance!

@gadapa-rakesh
Copy link
Author

I tried passing the cors option as the command argument and it worked fine.

$ python -m rasa_core.server -d models/dialogue/ -u models/nlu/current/ -o out.log --cors '*'

@tmbo
Copy link
Member

tmbo commented Dec 21, 2017

Yes, so the configuration within the config.json is the rasa NLU configuration - but since this is the rasa core server it doesn't use that option.

@tmbo tmbo transferred this issue from RasaHQ/rasa_core Mar 21, 2019
taytzehao pushed a commit to taytzehao/rasa that referenced this issue Jul 14, 2023
…aHQ#1880)

Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.11.5 to 0.11.6.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](moby/buildkit@v0.11.5...v0.11.6)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants