manatlan / guy

Graphics User Ynterface : a simple module for making GUI applications (with html/js) for py3 ... to target windows, linux, mac & android
Apache License 2.0
202 stars 23 forks source link

Improve CORS proxy #18

Closed icarito closed 4 years ago

icarito commented 4 years ago

In brief I want to use Guy and overcome CORS limitations on the Git API in order to use https://github.com/isomorphic-git/isomorphic-git. I know Guy is meant to be very brief and simple but I think that if done cleverly, adding methods to the built in proxy shouldn't add complexity...

So think of this as a feature request, maybe I'll find the time to dig into it, but can't promise.

I thought I'd share the idea here, ask if it's within scope and maybe get pointers. Thank you!

manatlan commented 4 years ago

What verbs do you need ?

Currently, there are GET, POST, PUT, HEAD, PATCH, DELETE, OPTIONS which are supported ootb ... I think it's enough for 99% cases ... but it's really easy to add more ;-)

The concept is easy ...

You write your js call ... with guy.fetch() instead of window.fetch() ...(exactly the same signature) .... when you use guy.fetch(), all http requests are done in server side, instead of client side. to avoid cors trouble.

that's all

Le sam. 2 mai 2020 à 06:19, Sebastian Silva notifications@github.com a écrit :

In brief I want to use Guy and overcome CORS limitations on the Git API in order to use https://github.com/isomorphic-git/isomorphic-git. I know Guy is meant to be very brief and simple but I think that if done cleverly, adding methods to the built in proxy shouldn't add complexity...

So think of this as a feature request, maybe I'll find the time to dig into it, but can't promise.

I thought I'd share the idea here, ask if it's within scope and maybe get pointers. Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/manatlan/guy/issues/18, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEZQU5NOYNJQYQII32VSLRPONLPANCNFSM4MXQWGAA .

icarito commented 4 years ago

Sorry for the radio silence. I gather from https://github.com/isomorphic-git/isomorphic-git/blob/9d3f0dede5e4384b418b0bf1252c0d1fd0f50c65/src/managers/GitRemoteHTTP.js that only GET and POST are required but I thought OPTIONS would be too. I'm working on a clean simple proof of concept to try things out, will post it when it's ready.

icarito commented 4 years ago

I'm sorry I had misdiagnosed the issue. It's not about the HTTP verbs. I see we have most (I previously missed OPTIONS when trying to use it for WebDAV protocol).

In this case it looks like Git implements a special HTTP 'smart' protocol and I'm not sure what we would be missing to use it.

I've pushed a proof of concept that fails with the most naive approach possible, to point the browser git client to location.origin + '/_/' + target_url but I keep getting:

SmartHttpError: Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: HTTP 404: Not Found

Or variations thereof.

I will continue to iterate with https://gitlab.com/fuentelibre/guit and see what we are missing. I will compare with https://github.com/isomorphic-git/cors-proxy/ which does the same thing. Any ideas welcome.

icarito commented 4 years ago

The latest commit in https://gitlab.com/fuentelibre/guit manages to get info over HTTPS. It just happens that github gists don't offer remote info or something like that. I was able to get from gitlab and github repositories.

I'll close this then!