0

I'm currently attempting to load a gltf model into my Aframe scene from Google Drive like this:

<a-entity gltf-model="url(https://drive.google.com/uc?export=view&id={redacted})"></a-entity>

But I'm getting the following error:

Access to XMLHttpRequest at 'https://drive.google.com/uc?export=view&id={redacted}' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I'm using a python SimpleHTTPServer configured to allow CORS from here: https://gist.github.com/mkows/cd2122f427ea722bf41aa169ef762001

When I upload an image to google drive and attempt to load that using <img src="https://drive.google.com/uc?export=view&id={redacted}" /> the image loads fine.

What could be wrong?

Matthew Kline
  • 71
  • 1
  • 6

1 Answers1

1

I'm using a python SimpleHTTPServer configured to allow CORS

Not for this.

That request is being serviced by the server responsible for drive.google.com, not localhost:8000.

You've applied the CORS headers to the wrong server.


Since you don't control Google Drive's response headers, consider hosting the file elsewhere (or proxying it through you own server, which is effectively the same thing).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Okay, for this project I don't have the freedom of hosting a web server so do you know if Dropbox or Onedrive would have the same issue? I'm just looking for a simple place to store and serve a few files for free. Any suggestions? – Matthew Kline May 20 '20 at 22:02
  • Also, any idea why an image loads fine but the model doesn't? – Matthew Kline May 20 '20 at 22:03
  • https://stackoverflow.com/a/35553666/19068 — see the section "Why you can display data in the page without reading it with JS " – Quentin May 20 '20 at 22:05
  • Thanks, update: just tried out mediafire and it works – Matthew Kline May 20 '20 at 22:20