Link above. Block in the project. Unfortunately, this block only supports "https://" websites. I'll be changing this soon. You do not need to add the "https://" either. Let me know if it works!
No, does not work for anything but a host-only URL.
There is a draft of basic cors-proxy, cors-proxy/server.py at master · runarfu/cors-proxy · GitHub
So why doesn't it work? I swear I tested it on Google, Youtube and Snap!. Does this repo provide the code I'm supposed to use?
So you tested any non-trivial URL, say
I've not run this code myself. It's just one of the first responses from the search engine. That repository seems to cope with the most obvious problems.
So I've changed the code but it still doesn't work.
Presumably Snap! isn't a cross-origin request. :~) As for the other two, I bet they explicitly allow cross-origin requests. Try a bank.
Replace your line 26 with
request = requests_function("https://"+url, stream=True, params=flask.request.args)
I started with github, applied dardoro's changes and now it works for me.
Most crucial parts:
@app.route('/<path:url>', methods=method_requests_mapping.keys()) def proxy(url): requests_function = method_requests_mapping[flask.request.method] request = requests_function("https://" + url, stream=True, params=flask.request.args) response = flask.Response(flask.stream_with_context( request.iter_content()), content_type=request.headers['content-type'], status=request.status_code) response.headers['Access-Control-Allow-Origin'] = '*' return response
It works! Except for some websites it returns a 404 error. I think because of the "/" in the URL path.
Ah. Thanks. But why was that so important?
<path:url> accepts "/" as its body, not as a parameters separator.
So is this technique legal?
I don't know man. Now I'm worried I'm about to be banned from Google for making GET requests. (that last one was a joke.)