Localhost server works for LibreOffice but not for Firefox, Thunderbird and Chromium

Hi,

Some information about my operating system:

  • My operating system: Linux Mint 20.3 based on Ubuntu 20.04 LTS.
  • Firefox version: 120.0, LanguageTool extension 8.3.0.
  • Thunderbird version: 115.5.0, LanguageTool extension 8.3.0.
  • Chromium version: 119.0.6045.159, LanguageTool extension 8.3.0.
  • LibreOffice version: 7.5.8.2 with internal LanguageTool code.
  • LanguageTool server version: 6.3.

I launch LanguageTool server with the following code, at system start:
“nohup java -cp ~/opt/LanguageTool/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 --allow-origin > /dev/null 2>&1 &”

Here is the test result in Chromium browser:
URL: “http://localhost:8081/v2/check?language=en-US&text=my+text
Result:
“{“software”:{“name”:“LanguageTool”,“version”:“6.3”,“buildDate”:“2023-10-06 20:34:38 +0000”,“apiVersion”:1,“premium”:false,“premiumHint”:“You might be missing errors only the Premium version can find. Contact us at supportlanguagetoolplus.com.”,“status”:”“},“warnings”:{“incompleteResults”:false},“language”:{“name”:“English (US)”,“code”:“en-US”,“detectedLanguage”:{“name”:“English (US)”,“code”:“en-US”,“confidence”:0.65618557,“source”:”+fallback"}},“matches”:[{“message”:“This sentence does not start with an uppercase letter.”,“shortMessage”:“”,“replacements”:[{“value”:“My”}],“offset”:0,“length”:2,“context”:{“text”:“my text”,“offset”:0,“length”:2},“sentence”:“my text”,“type”:{“typeName”:“Other”},“rule”:{“id”:“UPPERCASE_SENTENCE_START”,“description”:“Checks that a sentence starts with an uppercase letter”,“issueType”:“typographical”,“urls”:[{“value”:"https://languagetool.org/insights/post/spelling-capital-letters/“}],“category”:{“id”:“CASING”,“name”:“Capitalization”}},“ignoreForIncompleteSentence”:true,“contextForSureMatch”:-1}],“sentenceRanges”:[[0,7]]}”

When I use LibreOffice with LanguageTool internal code enabled, pointing to “http://localhost:8081/v2”, the corrections are done, LanguageTool works.

When I use Firefox, Thunderbird or Chromium with extensions settings pointing to local server, LanguageTool does not work. It simply fails (in Chromium, a message suggests relaunching the browser, but doing it changes nothing).

When I use Firefox, Thunderbird or Chromium with extensions settings pointing to cloud, LanguageTool works.

So, something seems broken in the latest extensions (versions 8.30).

Regards,

MN

1 Like

Please see if this helps: Self-hosted LanguageTool server and Chrome add-on - #4 by dnaber

1 Like

Hi,

I have tested adding “–config” after “–allow-origin”, and replacing “–allow-origin” by “–config”. In both cases, the server does not start, the test at localhost port 8081 (see above) says “localhost not reachable”.

Regards,

MN

You need to add --config and the path to a config file - this file can be empty, though.

java -jar languagetool-server.jar -h will print usage information.

1 Like

Hi,

Thanks, I have tested the workaround, and it now works with Firefox, Thunderbird, Chromium, and still with LibreOffice.

My command line is now:
“nohup java -cp ~/opt/LanguageTool/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 --allow-origin --config ~/.config/LanguageTool/config.txt > /dev/null 2>&1 &”
where “config.txt” has no content.

Regards,

MN

1 Like

Thanks!

touch ~/.config/LanguageTool/config.txt

Now, this edition of my startup script works (tested in Firefox on FreeBSD-CURRENT, without restarting the browser):

% cat ~/bin/bin/LanguageTool-startup.sh
#!/bin/sh
( cd /usr/home/grahamperrin/dev/LanguageTool && /usr/local/openjdk21/bin/java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 --allow-origin "*" --config ~/.config/LanguageTool/config.txt > /dev/null 2>&1 & )
( cd /usr/home/grahamperrin/dev/LanguageTool && /usr/local/openjdk21/bin/java -jar languagetool.jar --tray & )
% 

Thanks to CuatroTorres at https://forums.FreeBSD.org/posts/633712 for directing me here.

Your --allow-origin has no "*", is this intentional?


I’m comparing with https://dev.languagetool.org/http-server#starting-from-command-line without understanding the details. Please excuse my ignorance.