The first step was to create a basic website using Slim PHP. I always use my own, pre-made repo for this to ensure there are no errors.
The second step was to install the LT HTTP server on my host machine and enable it to run on startup as a systemd service by using the following configuration in /etc/systemd/system/languagetool.service
:
[Unit]
Description=LanguageTool Server
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/java -cp /opt/LanguageTool/languagetool-server.jar org.langu$
User=www-data
WorkingDirectory=/opt/LanguageTool
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Finally, I exposed the port by adding the following lines to my nginx configuration:
location /v2/check {
proxy_pass http://localhost:8081/v2/check;
}
At this point, I am able to utilise the LT API by issuing the following cURL command:
curl --data "language=en-US&text=a simple test" http://my.domain/v2/check
I have also tested with Postman, sending the data in the x-www-form-urlencoded
format.
Both tests are successful and I can see that the proper results are returned.
I have added the HTML from the LT documentation to my Slim template, updating the value of languagetool_rpc_url
to match the URL where the LT server is exposed.
Now, when I click on the ‘Check Text’ button, the request fails. I can see the error message, “Error: Did not get response from service. Please try again in one minute.” and when I inspect the source of this error message within the editor_plugin2.js
file, I can see that the AJAX request is failing.
Viewing details of the request in my browser’s code inspector, I can see that the correct endpoint was targeted (http://my.domain/v2/check) and is formatted properly with x-www-form-urlencoded
.
Without re-writing the editor_plugin2.js
script, I am at a loss. All of the elements work independently, but will not communicate. I am using everything out-of-the-box when it comes to LanguageTool. The only adaptations I have made are to expose port 8081 using nginx and to alter the value of languagetool_rpc_url
. Both of these changes are tested and working, as previously explained. I’ve no idea how to proceed in troubleshooting this. TIA!