XMLHttpRequest无法加载http:// localhost:9090 / receive。 请求的资源上不存在“ Access-Control-Allow-Origin”标头

I am opening a html file through nginx server and then the html file passes the "POST" request from the dropzone to the nginx server which then proxy_pass to my go server.This go server then accepts the request.

But when i try to use my html file and drop something in the dropzone i get the error :

XMLHttpRequest cannot load http://localhost:9090/receive. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9009' is therefore not allowed access.

PLease help me out.

In your error above you have the page loading from http://localhost:9009 requesting to http://localhost:9090/. These are different origins according to the Same Origin description here: http://tools.ietf.org/html/rfc6454#section-5

The origins must match:

  • scheme
  • host
  • port

For you the the scheme and host are the same, but the ports are different. Thus you will need to add the CORS headers to allow the caller to call your server on http://localhost:9090.