mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 22:43:41 -05:00
788009330c
[CE/SP] Hotfix 4.2.7/5.0.7 GitOrigin-RevId: e36a5af392c2356d4068a98acc2d637d879392f8
70 lines
2.4 KiB
Diff
70 lines
2.4 KiB
Diff
--- a/services/web/app/src/Features/Spelling/SpellingController.js
|
|
+++ b/services/web/app/src/Features/Spelling/SpellingController.js
|
|
@@ -28,39 +28,35 @@ module.exports = {
|
|
})
|
|
},
|
|
|
|
- proxyRequestToSpellingApi(req, res) {
|
|
+ proxyCheckRequestToSpellingApi(req, res) {
|
|
const { language } = req.body
|
|
|
|
- let url = req.url.slice('/spelling'.length)
|
|
-
|
|
- if (url === '/check') {
|
|
- if (!language) {
|
|
- logger.error('"language" field should be included for spell checking')
|
|
- return res.status(422).json({ misspellings: [] })
|
|
- }
|
|
+ if (!language) {
|
|
+ logger.error({}, '"language" field should be included for spell checking')
|
|
+ return res.status(422).json({ misspellings: [] })
|
|
+ }
|
|
|
|
- if (!languageCodeIsSupported(language)) {
|
|
- // this log statement can be changed to 'error' once projects with
|
|
- // unsupported languages are removed from the DB
|
|
- logger.debug({ language }, 'language not supported')
|
|
- return res.status(422).json({ misspellings: [] })
|
|
- }
|
|
+ if (!languageCodeIsSupported(language)) {
|
|
+ // this log statement can be changed to 'error' once projects with
|
|
+ // unsupported languages are removed from the DB
|
|
+ logger.debug({ language }, 'language not supported')
|
|
+ return res.status(422).json({ misspellings: [] })
|
|
}
|
|
|
|
const userId = SessionManager.getLoggedInUserId(req.session)
|
|
- url = `/user/${userId}${url}`
|
|
+ const url = `${Settings.apis.spelling.url}/user/${userId}/check`
|
|
req.headers.Host = Settings.apis.spelling.host
|
|
return request({
|
|
- url: Settings.apis.spelling.url + url,
|
|
- method: req.method,
|
|
+ url,
|
|
+ method: 'POST',
|
|
headers: req.headers,
|
|
json: req.body,
|
|
timeout: TEN_SECONDS,
|
|
})
|
|
.on('error', function (error) {
|
|
- logger.error({ err: error }, 'Spelling API error')
|
|
+ logger.error({ err: error }, 'Spelling Check API error')
|
|
return res.status(500).end()
|
|
})
|
|
.pipe(res)
|
|
},
|
|
-}
|
|
+}
|
|
\ No newline at end of file
|
|
|
|
--- a/services/web/app/src/router.js
|
|
+++ b/services/web/app/src/router.js
|
|
@@ -1083,7 +1083,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
|
webRouter.post(
|
|
'/spelling/check',
|
|
AuthenticationController.requireLogin(),
|
|
- SpellingController.proxyRequestToSpellingApi
|
|
+ SpellingController.proxyCheckRequestToSpellingApi
|
|
)
|
|
webRouter.post(
|
|
'/spelling/learn',
|