Closed thomasyu888 closed 9 years ago
Hi Tom,
I don't know if you could get that to work or not, the solution is out of the client's control. I don't know how the "shortner" works, but apparently is not forwarding the CORS headers from the original server response. Google "CORS" for more info on the topic.
Jim
Dear Jim,
Thank you in advance for your time. I was wondering if there was a way to get redirection to work. So example: I put this link in google shortner:
http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeBroadHistone/wgEncodeBroa>dHistoneGm12878H3k4me3StdSig.bigWig <http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeBroadHistone/wgEncodeBroa%3EdHistoneGm12878H3k4me3StdSig.bigWig> and got this link: goo.gl/nA0Udx
When i embed this shortened link. this error appears.
error https://cloud.githubusercontent.com/assets/10556275/8810322/281794cc-2fa3-11e5-957f-45d0a723e228.png
Please kindly let me know if you have any ideas for going about this.
Best, Tom
— Reply to this email directly or view it on GitHub https://github.com/igvteam/igv.js/issues/134.
Actually scratch that, CORS might be a problem but the error you see is actually not an error, or rather not a fatal one. The root problem here is igv doesn't know the file type and is guessing. Since your shortened URL does not have a "bigWig" index you will have to set that explicitly. There is a property for that, try setting "format: bigwig" as a property of the track config object.
{ url: 'http://goo.gl/nA0Udx', format: 'bigwig', name: 'shortened bigwig' }
I just tried it, didn't work. CORS is the issue, the server is not setting the required headers. The UCSC server does, so I assume the shortened URL goes through a proxy that is not relaying those headers.
Dear Jim,
Thank you for all your help. Unfortunately since we would potentially want to integrate this into our open source platform (synapse), we would be using URL's which get redirected. Is there a way around this at all?
Best, Tom
There is no way to hack around CORS on the client, if that's what you mean. This is fundamental to javascript. Actually CORS headers are a great improvement, before them you absolutely could not make XmlHttpRequests to origins other than the page origin. So for a general pure client-side solution you are going to have to insure that the response to load requests have CORS headers unless the origin of the response is the same as the html page that loaded the javascript.
There are workarounds if you can run your own proxy. Basically the proxy should run from the same origin as your page, and it will make the requests to the remote server on the clients behalf.
Google "Cross Origin Scripting CORS" for more info.
Dear Jim,
Thank you for all your help. Unfortunately since we would potentially want to integrate this into our open source platform (synapse), we would be using URL's which get redirected. Is there a way around this at all?
Best, Tom
— Reply to this email directly or view it on GitHub https://github.com/igvteam/igv.js/issues/134#issuecomment-123458534.
Dear Jim,
Thank you for your help!
Best, Tom
Here are some links that might be helpful, I didn't do an exhaustive search but this problem (url shortening & javascript) would be so common that there must be solutions.
http://platinumdogs.me/2014/08/22/using-url-shortening-services-from-the-client-with-javascript/
Dear Jim,
Thank you in advance for your time. I was wondering if there was a way to get redirection to work. So example: I put this link in google shortner:
When i embed this shortened link. this error appears.
Please kindly let me know if you have any ideas for going about this.
Best, Tom