Search code examples
python-3.xcorschatbotrasa-nlurasa

POST request changes to OPTIONS in RASA


The postman post request return a response from RASA NLU, however when replicating the same thing via the browser, the post request changes from POST request to OPTIONS request and there is no response from RASA NLU API.


Solution

  • To fix this issue, you need to pass the command option

    --auth-token < put your custom token here >

    You can also pass None as auth token which is the default option as follows.

    rasa run -m models --enable-api --log-file out.log --cors "*"  --endpoints endpoints.yml --debug --auth-token None
    

    Also you need to change your POST request by adding the token as payload.

    for example:

    $.ajax({
      url: 'http://localhost:5005/webhooks/rest/webhook/',
      method: 'POST',
      contentType: 'application/json',
      data: JSON.stringify({
        message: msg,
        sender: name,
        token: 'None'
      })
    

    Restart the NLU server and clear cached JavaScript if present by hitting CTRL+SHIFT+R. Now the CORS policies should not be a problem.