overleaf/services/web/app/coffee/Features/Spelling/SpellingController.coffee

16 lines
574 B
CoffeeScript
Raw Normal View History

2014-02-12 05:23:40 -05:00
request = require 'request'
Settings = require 'settings-sharelatex'
logger = require 'logger-sharelatex'
2015-10-22 15:15:50 -04:00
TEN_SECONDS = 1000 * 10
2014-02-12 05:23:40 -05:00
module.exports = SpellingController =
proxyRequestToSpellingApi: (req, res, next) ->
url = req.url.slice("/spelling".length)
url = "/user/#{req.session.user._id}#{url}"
req.headers["Host"] = Settings.apis.spelling.host
2015-10-22 15:15:50 -04:00
request(url: Settings.apis.spelling.url + url, method: req.method, headers: req.headers, json: req.body, timeout:TEN_SECONDS)
.on "error", (error) ->
2014-02-12 05:23:40 -05:00
logger.error err: error, "Spelling API error"
2015-10-22 15:15:50 -04:00
.pipe(res)