amazon web services - AWS S3 - No 'Access-Control-Allow-Origin' header is present on the requested resource -
i have client static website on s3 (app.foo.org) sending http requests web application running on elastic beanstalk (www.foo.org).
the s3 web application configuration is:
<?xml version="1.0" encoding="utf-8"?> <corsconfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <corsrule> <allowedorigin>*</allowedorigin> <allowedmethod>get</allowedmethod> <allowedheader>*</allowedheader> </corsrule> </corsconfiguration>
on s3 application set http headers cors. on server set response headers following:
httpresponse.setheader("access-control-allow-origin", "*"); httpresponse.setheader("access-control-allow-methods", "get, post, delete, put"); httpresponse.setheader("access-control-allow-headers", "x-requested-with, content-type");
everything working fine, when upload new version of static website on s3 via "aws async" command, stopped working! , following error:
xmlhttprequest cannot load http://www.foo.org/rest/...
no 'access-control-allow-origin' header present on requested resource. origin 'http://app.foo.org' therefore not allowed access. response had http status code 500.
i tried changing corsrules: instance replace: <allowedorigin>*</allowedorigin> with: <allowedorigin>http://*</allowedorigin> <allowedorigin>https://*</allowedorigin>
i tried many other suggestions find... nothing works.. idea can wrong?
i found bug!
the client sending http requests, while on server side, converted coming http://www.foo.org requests https://www.foo.org , send back, , expected client send me https request.
so set client send https requests , works fine!
Comments
Post a Comment