Apress / building-chatbots-with-python

Source Code for 'Building Chatbots with Python' by Sumit Raj
Other
101 stars 75 forks source link

Running UI on localhost #5

Open GDBSD opened 5 years ago

GDBSD commented 5 years ago

One of the most obvious omissions in the book and in the code is lack of instructions for deploying the UI on localhost. The Heroku deployment is of limited use, particularly for those of us who want to do a POC for our company. Most companies frown on any code developed on company time being deployed to a public platform. If I was a stronger front-end developer solving this would probably be trivial; but I am not. And I've fussed around trying to get the sample UI running for hours without success. Results:

Command line: INFO __main__ - Action endpoint is up and running. on ('0.0.0.0', 5055) Browser: http://localhost:5055/health produces {"status":"ok"} Browser: http://localhost/webhooks/rasa/chat produces: This site can’t be reached and localhost refused to connect

sumit12dec commented 5 years ago

@GDBSD I can understand your frustration given you are not much into frontend development.

The reason why it doesn't work on localhost is due to the fact that modern browsers do not allow CORS. https://en.wikipedia.org/wiki/Cross-origin_resource_sharing

I had thought of explaining doing it on localhost only to avoid deployment on Heroku or any other cloud platform but it required another set of workarounds to be done.

Trying installing this chrome extension https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en

and try to access the endpoint on your localhost. This extension is used by frontend developer to skip CORS validation by browsers while development.

Let me know if it works for you.

Regards, Sumit