gallegretti / escala

Escala: A web based score editor
https://gallegretti.github.io/escala/
MIT License
16 stars 0 forks source link

Read mode only #11

Open ljfreelancer88 opened 1 year ago

ljfreelancer88 commented 1 year ago

Is it okay to have a read mode only? This read mode can only see related to player only. The use case is, say I want to forward the link (ex. https://gallegretti.github.io/escala/?piece=online-link-to-guitar-pro-or-xml.gp4) to the band.

Thank you in advance

gallegretti commented 1 year ago

I like the idea, but this is tricky because of CORS. If you grab a score from the internet, it mostly like won't work because of the Access-Control-Allow-Origin header that it returns when you try to GET it. So it's not a good idea to implement it this way because it won't work for most files and people won't understand why. A reverse proxy could solve it, but then it involves hosting and other costs.

ljfreelancer88 commented 1 year ago

How about parse and read the URL and get the host(domain) and pass it to the header to allow CORS?

...or if it still tricky. How about add "switch" for read mode only? (ex. https://gallegretti.github.io/escala/?mode=read) I guess, I'll have to send it manually the file to upload.

gallegretti commented 1 year ago

Unfortunately, the header Access-Control-Allow-Origin is controlled by the server in the response. Here's an example. First, I'm trying to load a score from the same origin (cifraclub.com.br). It works fine:

image

But if I try to do the same fetch request on another domain (gallegretti.github.io), it won't work:

image

The request could only work if the server was allowing cross-origin requests with the Access-Control-Allow-Origin header, or if the server was in the same origin. You can read more about it here. So yes, you'll need to send the file manually, and I don't think a read-only mode is very useful by itself, without this feature that you are proposing.