mdenet / platformtools

Education platform tool functions.
Eclipse Public License 2.0
0 stars 3 forks source link

Xtext tool cannot be used cross origin #68

Open barnettwilliam opened 6 months ago

barnettwilliam commented 6 months ago

Trying to use the Xtext tool service in a cross origin configuration editor instances autocompletion and validation do not work. This was seen when setting up the new ep.mde-network.org domain and trying to use the Xtext tool on mdenet-ep.sites.er.kcl.ac.uk/tools/xtext.

Until this issue is solved, it will not be possible to create an activity using the Xtext tool service from another education platform instance on a different domain. Workaround:

Details

Configuring the Xtext tool services Access-Control-Allow-Origin headers to allow all origins in the following places the editor instances autocompletion and validation do not work due to CORS errors.

(There is a separate issue to use environment variables to configure these https://github.com/mdenet/platformtools/issues/38). .

Things to look into

  1. How the editor instance java service's CORS header is set and see if there is a way to set it to all origins "". The cors origin value may be being derived from the createEditor() parameter baseUrl and serviceUrl in which case require changes as per 3 alternatively there may be a way to override this in the generated java service war in web.xml similar to how CORS setttings are being set in xtext/acemodebundler/web.xml* or even globally overriding this globally in the editor server tomcat config.

  2. Another thing I suspect would be the Xtext web editor createEditor() method that is called in XtextEditorPanel.initialize(). We may not be calling createEditor() correctly as per the documentation there are lots of options and there may also be some undocumented behaviour, so changing the parameters may be able get fully stateless working.

  3. If something if something identifiable in createEditor() is preventing this from working it would be possible to customise it in platform/src/xtext/2.31.0/xtext-ace.js

  4. Bigger changes would be to try different editors or Xtext's LSP.