I am not yet succeeding in making CORS requests work in my project, basically a Play server and an AngularJS web client.
Since there are many variables to take into consideration, I would like first to be sure that everything is ok at least on the Play server side. But, my fault, the Play 2.4 documentation on CORS is not enough to help me figure out a concrete use case.
Two basic questions:
app/controllers/Mycontr.scala
app/conf/routes
Tried to find a complete tutorial, but had no luck for Play 2.4
"root of your project" means a directory which corresponds to the package root. It is app/
by default, src/main/scala/
when using default sbt layout . That's all.
I am running into the same, issue, it keeps saying:
XMLHttpRequest cannot load http://localhost:9000/fetchBetween . Response to preflight request doesn't pass access control check: No 'Access-Control Allow-Origin' header is present on the requested resource. Origin ' http://localhost:3000 ' is therefore not allowed access. The response had HTTP status code 404.
I added Filters.scala
to my app/
folder, and added filters
to libraryDependencies
, this is my config in application.conf
:
play.filters.cors {
pathPrefixes = ["/fetchBetween"]
allowedOrigins = ["*"]
allowedHttpMethods = ["GET", "POST"]
allowedHttpHeaders = ["Accept"]
preflightMaxAge = 3 days
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.