javascript - CORS header not set - can I request an image url and then serve it back to myself? -
i attempting populate webgl earth meshes compiled images. these images cross-domain, , hosted on server setting appropriate headers isn't option. can xmlhttprequest image urls, , serve them myself via php bypass cors errors?
or, more specifically, can use own webserver proxy serve img urls myself (to around cors) in webgl context?
edit: real question here if can use own webserver proxy pass urls, or if i'll have download each image server use it.
i had similar issue once using api. first tried in js getting same error message do.
my solution switch php , server side since modern browsers block want do.
so yes, possible.
get pictures on backend , provide them frontend.
simply retrieve pictures first , send them output browser. can synchronously doing like:
$ch = curl_init ... ... $pic = curl_exec ... // picture // , echo
this have done once don't remember correctly. or can async, done when using img-tags. i'm not sure how works webgl should similar:
- download pic filesystem
- then provide url browser.
it depends on how big images are, how long need them, , api whether want go direction.
answer first comment:
tricky. don't have experience using webgl earth , whether possible load data async via ajax (look here) or if use angularjs (look here) it. need try 1 out. i'd loading times.
there api-call http://example.com/api/get_image/65446
downloads picture, resizes , sends browser.
what in case is:
- send 'normal' page user
- then there events want show pictures
- when event happened use api-call mentioned , add page success handler. again, how can work webgl earth question can't answer.
and if want use mobile devices need think picture size. since screens relatively small should make pics smaller first. then, how long take picture guess biggest challenge. wants scrolls globe see pictures immediately, not after 5 seconds (since scrolled more probably)
think whether can prepare download , resize first. if want show pictures, 10.000 in total that. don't need think loading times , when delete pictures. should open question topic , try first whether ajax possible.
Comments
Post a Comment