TEIC / TEI

The Text Encoding Initiative Guidelines
https://www.tei-c.org
Other
269 stars 88 forks source link

Website Issue: tei-c.org CORS blocks retrieval of schemas, etc. #2437

Closed jamescummings closed 1 year ago

jamescummings commented 1 year ago

External systems trying to use off-the-shelf TEI-C schemas often have difficulty because some resources can be blocked by CORS. For example, a GitLab issue on LEAF-Writer Luciano Frizzera @lucaju points out:

LEAF-Write does its best to load the document's schema and CSS from an external URL. However, some external resources can be blocked by CORS. For instance, tei-c.org does not allow external connections, so LEAF-Writer cannot load schemas from this domain. The request could also fail due to error 400-500 or loss of internet connection.

Is there a way we can enable other systems grabbing TEI schemas easily? What is needed to do so? The current work-around is to get them from Jenkins (presumably the stable TEI P5 release versions), but that seems less than optimal.

peterstadler commented 1 year ago

Another workaround might be to use the dedicated host/subdomain https://vault.tei-c.org which serves the same content as https://tei-c.org/Vault from a different – CORS-enabled – server.

lucaju commented 1 year ago

Workarounds like using Jenkins or vault.tei are fine. They work well. And that is what we have been doing.

The issue is that LEAF-Writer is a web editor; it only works on the browser without the need or reliance on a server. It relies on the schema declaration of a document to retrieve the schema file.

Sure, we can manipulate the URI, but it defeats the purpose of linked data. I mean, the XLM points to a specific schema (and perhaps to a specific version of a schema). Why would the editor get it elsewhere if the schema is publicly available in the URI?

The solution we implemented involved alternative routes to get the schema. First, we try the URI in the file (e.g., from tei-c). If it fails, we try to get it from Jenkins.

Unless there is a good reason to block the browser from fetching schemas from tei-c, I believe this is an easy technical problem to solve.

peterstadler commented 1 year ago

I had a look at the web server configuration and the Vault at https://tei-c.org/Vault/ already has CORS enabled. I do not see any reason why /release shouldn't have CORS enabled too so I will go ahead and add it.

peterstadler commented 1 year ago

Done. @lucaju / @jamescummings can you please try again and close the issue if successful?

lucaju commented 1 year ago

@peterstadler . Thank you for doing this.

Not sure if I a doing something wrong, but the request is still be blocked by CORS.

To be more specific, and give an example, people have document point to this schema: https://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng

I attached an image so you can see the error we are getting. I don't know if helps, but you can see it by yourself if you follow this link: https://leaf-writer.leaf-vre.org/edit?sample=Sample%20TEI%20letter (open the console to see the error).

Screenshot 2023-05-26 at 9 31 44 AM
hcayless commented 1 year ago

@lucaju Try it again. There was another location directive in our config that was interfering.

peterstadler commented 1 year ago

Looks good to me now (tested with https://leaf-writer.leaf-vre.org/edit?sample=Sample%20TEI%20letter)

Bildschirmfoto 2023-05-26 um 16 52 39

Thanks @hcayless

lucaju commented 1 year ago

Perfect. It is working for me too. Thank you @peterstadler