0

im trying to use jquery file upload to post files to a fileserver written in tornado. while i can post a file to the same domain i have issues if my fileserver is on a different domain or a subdomain of the origin. lets say from mydomain.com to files.mydomain.com

on the tornado web handler i set up an OPTIONS and a POST handler. the options function looks like this:

def options(self):
    self.set_header('Access-Control-Allow-Origin', '*')
    self.set_header('Access-Control-Allow-Methods', 'POST, OPTIONS')
    self.set_header('Access-Control-Max-Age', 1000)
    self.set_header('Access-Control-Allow-Headers', '*')
    self.set_status(200)

in the console i get a

XMLHttpRequest cannot load http://files.mycomain.com/upload. Origin http://mydomain.com is not allowed by Access-Control-Allow-Origin.

but the response shows that the Access-Control-Allow-Origin header is set to *.

how can i make this thing work?

aschmid00
  • 7,038
  • 2
  • 47
  • 66

1 Answers1

2

You cannot directly send ajax requests across domains due to the same origin policy. If you want to upload a file to a different domain, you'll need the server (on the same domain) to act as a proxy for the upload.

See also:

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • For the same reason. You can use the `document.domain` workaround described in the other q&a I linked. – Matt Ball Apr 27 '11 at 15:06
  • the issue im having right now is that my app is on GAE and i need to store big files (even 500mb and more). i didn't want to use the blobstore to keep those huge files. i cant even use a proxy like [downy](http://code.google.com/p/downy/) to redirect the request body to my fileserver cause of the 10sec urlfetch limit. i wont be able to send a 600mb files within those seconds. – aschmid00 Apr 27 '11 at 15:21