The current HTTP server is ideal to process curl request within the shell, but does not have any form of authentication: this make it susceptible to DoS attacks interfering with normal use: while token are generated, normal request get error codes.
I suggest adding a login/password mechanism: the simplest would be the Authorization: Basic <credentials> header, where credentials is the base64 encoding of ID and password joined by a single colon, as specified by RFC 7617 and 2617.
This is only meant to protect against direct firewall misconfiguration or portscanning when deploying on a forwarded port.
Protecting against captured/replayed HTTP traffic can be done separately by using an HTTPS proxy like stunnel.