Use --cors parameter with docker-compose image

Hello guys,

i want to run rasa core and nlu in a docker via docker-compose.

my docker-compose.yml looks like this:

version: '3.0'

services:
    rasa_core:
        image: rasa/rasa_core:latest
        ports:
            - 5005:5005
        volumes:
            - ./models/rasa_core:/app/models
            - ./config:/app/config
        command:
            - start
            - --core
            - models
            - -c
            - rest
            - --endpoints
            - config/endpoints.yml
            - -u
            - current/
    rasa_nlu:
        image: rasa/rasa_nlu:latest-spacy
        volumes:
            - ./models/rasa_nlu:/app/models
            - ./config:/app/config
        command:
            - start
            - --path
            - models
            - -c
            - config/nlu_config.yml
    action_server:
        image: rasa/rasa_core_sdk:latest
        volumes:
            - ./actions:/app/actions

now when i try to talk to the bot with curl -X POST localhost:5005/parse --data '{"q":"hello"}' i get the expected result. However, when i try to send a POST request from my local website via javascript, i get a cors error.

Now i know there is/can be a --cors parameter that can be set to “*” which should work for me. But i don’t know where to set this parameter.

I tried entering it under the command section of the docker for nlu and/or core, but neither worked.

I also tried setting the cors_origins: "*" option in my nlu_config.yml

Can someone explain to me how to get rid of this cors error and send POST requests from the browser?

Thanks in advance

Hi @LoganDungeon, sorry, your question did not get answered yet. As soon as I have time, I’ll take a look and get back to you.

Hi, I have seen --cors "*" added under the command: line

As stated above I have already tried that in several ways. But adding - --cors "*" yields the following error:

rasa_nlu_1       | usage: server.py [-h] [-e {wit,luis,dialogflow}] [-P PORT]
rasa_nlu_1       |                  [--pre_load PRE_LOAD [PRE_LOAD ...]] [-t TOKEN] [-w WRITE]
rasa_nlu_1       |                  --path PATH [--cors [CORS [CORS ...]]]
rasa_nlu_1       |                  [--max_training_processes MAX_TRAINING_PROCESSES]
rasa_nlu_1       |                  [--num_threads NUM_THREADS] [--endpoints ENDPOINTS]
rasa_nlu_1       |                  [--wait_time_between_pulls WAIT_TIME_BETWEEN_PULLS]
rasa_nlu_1       |                  [--response_log RESPONSE_LOG] [--storage STORAGE] [-c CONFIG]
rasa_nlu_1       |                  [--debug] [-v]
rasa_nlu_1       | server.py: error: unrecognized arguments: --cors "*"
rasa_core_1      | usage: run.py [-h] -d CORE [-u NLU] [-v] [-vv] [--quiet] [-p PORT]
rasa_core_1      |               [--auth_token AUTH_TOKEN] [--cors [CORS [CORS ...]]]
rasa_core_1      |               [--enable_api] [-o LOG_FILE] [--credentials CREDENTIALS]
rasa_core_1      |               [-c CONNECTOR] [--endpoints ENDPOINTS] [--jwt_secret JWT_SECRET]
rasa_core_1      |               [--jwt_method JWT_METHOD]
rasa_core_1      | run.py: error: unrecognized arguments: --cors "*"

That is the error I got from adding the cors parameter to both core and nlu. Both of them show the cors parameter in the usage, but throw the error that they don’t recognize it.

Adding

- --cors
- "*"

Results in no launch error, but the cors error still persists.

I also opened a Github issue, but unfortunately it got no further responses for a week.