I am using AngularJS to do this.
Unfortunately, CORS (Cross-origin resource sharing) is not supported in Discourse (or I didn’t see a configuration option ).
Temporarily, I’ve added the gem rack-cors (GitHub - cyu/rack-cors: Rack Middleware for handling Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible.) to my Discourse instance, and added the middleware. It works perfectly and I was able to request the Discourse API from my external website.
Would you accept a pull request adding this gem and maybe some configuration settings for it ?