pr_19297.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --- a/services/web/app/src/Features/Spelling/SpellingController.js
  2. +++ b/services/web/app/src/Features/Spelling/SpellingController.js
  3. @@ -28,39 +28,35 @@ module.exports = {
  4. })
  5. },
  6. - proxyRequestToSpellingApi(req, res) {
  7. + proxyCheckRequestToSpellingApi(req, res) {
  8. const { language } = req.body
  9. - let url = req.url.slice('/spelling'.length)
  10. -
  11. - if (url === '/check') {
  12. - if (!language) {
  13. - logger.error('"language" field should be included for spell checking')
  14. - return res.status(422).json({ misspellings: [] })
  15. - }
  16. + if (!language) {
  17. + logger.error({}, '"language" field should be included for spell checking')
  18. + return res.status(422).json({ misspellings: [] })
  19. + }
  20. - if (!languageCodeIsSupported(language)) {
  21. - // this log statement can be changed to 'error' once projects with
  22. - // unsupported languages are removed from the DB
  23. - logger.debug({ language }, 'language not supported')
  24. - return res.status(422).json({ misspellings: [] })
  25. - }
  26. + if (!languageCodeIsSupported(language)) {
  27. + // this log statement can be changed to 'error' once projects with
  28. + // unsupported languages are removed from the DB
  29. + logger.debug({ language }, 'language not supported')
  30. + return res.status(422).json({ misspellings: [] })
  31. }
  32. const userId = SessionManager.getLoggedInUserId(req.session)
  33. - url = `/user/${userId}${url}`
  34. + const url = `${Settings.apis.spelling.url}/user/${userId}/check`
  35. req.headers.Host = Settings.apis.spelling.host
  36. return request({
  37. - url: Settings.apis.spelling.url + url,
  38. - method: req.method,
  39. + url,
  40. + method: 'POST',
  41. headers: req.headers,
  42. json: req.body,
  43. timeout: TEN_SECONDS,
  44. })
  45. .on('error', function (error) {
  46. - logger.error({ err: error }, 'Spelling API error')
  47. + logger.error({ err: error }, 'Spelling Check API error')
  48. return res.status(500).end()
  49. })
  50. .pipe(res)
  51. },
  52. -}
  53. +}
  54. \ No newline at end of file
  55. --- a/services/web/app/src/router.js
  56. +++ b/services/web/app/src/router.js
  57. @@ -1083,7 +1083,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
  58. webRouter.post(
  59. '/spelling/check',
  60. AuthenticationController.requireLogin(),
  61. - SpellingController.proxyRequestToSpellingApi
  62. + SpellingController.proxyCheckRequestToSpellingApi
  63. )
  64. webRouter.post(
  65. '/spelling/learn',