axa-group / nlp.js

An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more
MIT License
6.28k stars 621 forks source link

Is there possibility to use bot with https? #1223

Closed Reg93 closed 1 year ago

Reg93 commented 1 year ago

Hello! I checked other issues but didn't find where https is mentioned. Is there options which can make server work on https? I have such code in project now


{
  "settings": {
    "nlp": {
      "corpora": [{ "filename": "./corpora/qna.tsv", "importer": "qna", "locale": "en" }]
    },
    "api-server": { "port": 3000, "serveBot": true, "clientPath": "./public"}
  },
  "use": ["Basic", "Qna", "LangEn", "ExpressApiServer", "DirectlineConnector"]
}
``
aigloss commented 1 year ago

Hi @Reg93 ,

as of now, there is no out of the box support for https.

When using the ExpressApiServer component, the server is created here: https://github.com/axa-group/nlp.js/blob/b9f04e9fd12bd83f8abdf4a3946779d9b939e42c/packages/express-api-server/src/express-api-server.js#L79-L82 What you can do, is to create a custom component, extending the current ExpressApiServer, and overwrite the start method to create an HTTPS server instead of the default HTTP one (you can check the express method docs on that listen method for more details (https://github.com/expressjs/express/blob/8368dc178af16b91b576c4c1d135f701a0007e5d/lib/application.js#L612-L636).

Finally, just register your plugin instead of the ExpressAPIServer one.

OR

Modify the current ExpressApiServer so that it supports both modes, and contribute with the change :grimacing:

jesus-seijas-sp commented 1 year ago

This was intentional by design. Usually, you'll deploy into a cloud, and the certificates will be managed, so you don't really need to have the cert management in the development. If you are deploying on-premise, you usually configure a reverse proxy like Nginx, which already will take care of the certs.

Reg93 commented 1 year ago

This was intentional by design. Usually, you'll deploy into a cloud, and the certificates will be managed, so you don't really need to have the cert management in the development. If you are deploying on-premise, you usually configure a reverse proxy like Nginx, which already will take care of the certs.

Thank you!