samedi 5 avril 2014

Play Framework Error: No 'Access-Control-Allow-Origin' header is present with multi-dimensional JSON


Vote count:

0




So I'm trying to do a post on a webservice I've built with Play framework. I use an ajax call to make the request and post some JSON:



var post = $.ajax({
type:"POST",
url:"http://ift.tt/1fOaT0N",
data:'{"name":"Double product fdsfdsdf","sku":"3432432432","price":{"value":"22.0","curency":{"key":"USD"}}}'
})


However, I keep getting this error:



undefined
XMLHttpRequest cannot load http://ift.tt/1fOaT0N. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:2333' is therefore not allowed access.


Here are my settings on Play:



object Global extends GlobalSettings {

/**
* Global action composition.
*/
override def doFilter(action: EssentialAction): EssentialAction = EssentialAction { request =>
action.apply(request).map(_.withHeaders(
"Access-Control-Allow-Origin" -> "*",
"Access-Control-Allow-Methods" -> "POST, GET, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Credentials" -> "true"
))
}
}


Any idea what's going on? Thanks!!



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire