XMLHttpRequest.open( “http://agent.electricimp.com/key”, “POST” )
XMLHttpRequest.setRequestHeader( “Origin”, “http://www.mywebdomain” )
XMLHttpRequest.setRequestHeader( “Content-Length”, “12” )
XMLHttpRequest.setRequestHeader( "Content-Type, “application/x-www-form-urlencoded” )
and in an agent I use:
res.header( "Access-Control-Allow-Origin", "http://www.mywebdomain" ); res.header( "Access-Control-Allow-Methods", "POST" ); res.header( "Access-Control-Allow-Headers", "Content-Type" ); res.header( "Access-Control-Allow-Headers", "Content-length"); res.send( 200, "The temperature at home is " + format( "%3.1fC", msg.temperature ) );
And this is partialy working in Firefox (no XML Headers returned), but gives warning in Explorer and then works.
Does using a wild card work?
Have you missed the colon: at the end of each Origin,Methods etc
Yes wildcard works in exactly the same way as domain. Yes I have missed the colons, think the IMP commands are inserting these as it fails completly if i put them in?
Sure this is something realy simple. Its just not jumping out at me.
I don’t know whether it’s related to your actual problem, but this isn’t going to do what you expect:
res.header( "Access-Control-Allow-Headers", "Content-Type" ); res.header( "Access-Control-Allow-Headers", "Content-length");
The agent HTTP implementation doesn’t deal with repeated headers. You need to combine those into a single header:
res.header( "Access-Control-Allow-Headers", "Content-Type, Content-length");