score:2
Accepted answer
this is play framework issue with cordova. the following link will explain it:
https://forum.ionicframework.com/t/ionic-http-request-with-403-error-on-ipad-device/50269/3
reason:
cordova sends a request through having header origin: file://…
you can check this link to deal with that play! 2.4: how to allow cors from origin file://
remove default course filter which you import from play framework and write your condition based filter:
import play.api.logger
import play.api.libs.concurrent.execution.implicits.defaultcontext
import play.api.mvc._
import play.mvc.http
/**
* allow cors from anywhere, any method
*/
class corsfilter extends essentialfilter {
def apply(nextfilter: essentialaction) = new essentialaction {
def apply(requestheader: requestheader) = {
nextfilter(requestheader)
.map { result =>
if (requestheader.method.equals("options")) {
results.ok.withheaders(
http.headernames.access_control_allow_origin -> "*",
http.headernames.access_control_allow_headers -> "access-control-allow-origin,x-requested-with, accept, content-type,application, iduser, access-control-allow-methods, token, access-control-allow-credentials, authorization",
http.headernames.access_control_allow_methods -> "head,get,post,put,patch,delete")
} else {
result.withheaders(
http.headernames.access_control_allow_origin -> "*",
http.headernames.access_control_allow_headers -> "x-requested-with, accept, content-type",
http.headernames.access_control_allow_methods -> "head,get,post,put,patch,delete",
http.headernames.access_control_expose_headers -> "x-custom-header-to-expose")
}
}
}
}
}
Source: stackoverflow.com
Related Query
- CORS issue(403) in Ionic using Scala
- Pros and cons of using sbt vs maven in Scala project
- How to update a mongo record using Rogue with MongoCaseClassField when case class contains a scala Enumeration
- How to parse JSON in Scala using standard Scala classes?
- Difference between using App trait and main method in scala
- Class broken error with Joda Time using Scala
- Scala capture group using regex
- Using Scala traits with implemented methods in Java
- Scala on iOS using Avian
- Using varargs from Scala
- Using Either to process failures in Scala code
- Using partial functions in Scala - how does it work?
- Using Scala from Java: passing functions as parameters
- Using scala constructor to set variable defined in trait
- Using Eithers with Scala "for" syntax
- Scala: How can I replace value in Dataframes using scala
- FoldLeft using FoldRight in scala
- Using a Java library with Scala reserved words
- Using SBT from Scala IDE
- How do I call a Scala Object method using reflection?
- Concatenating datasets of different RDDs in Apache spark using scala
- Using Java libraries in Scala
- Is using Scala on Android worth it? Is there a lot of overhead? Problems?
- Using Scala 2.12 with Spark 2.x
- Implementing yield (yield return) using Scala continuations
- Scala - No TypeTag Available Exception when using case class to try to get TypeTag?
- How to load JSON file using Play with Scala
- Unsupported version error using JTDS with Scala
- Scala compile server error when using nailgun
- Applying an argument list to curried function using foldLeft in Scala
More Query from same tag
- QtJambi won't construct a QApplication - Scala
- Write code that shows the difference in salaries between the top-paid employee and others per department
- Why "reading from a file" is not pure function?
- createOrReplaceTempView is not a member of org.apache.spark.rdd.RDD
- Transforming an `Option[Tuple]` in a scalaz `\/`
- How to FlatMap Option while Preserving When Empty
- How to pool the connections of mongodb with casbah?
- Best way to turn a Lists of Eithers into an Either of Lists?
- Reactive Mongo could not find reader when wrapping .getAs()
- Why exactly is prepend to a Scala List a constant time operation, but append a linear time operation?
- reformat spark-streaming dstream count with print
- How can I connect to a postgreSQL database into Apache Spark using scala?
- Scala + Spark: ways to pass parameters in a program. Is it possible to use the Context for this?
- scala parsing with nested parens
- Akka Stream Graph parallelisation
- Calling Clojure classes in Scala code
- how to filter out boolean fields in spark dataframe?
- Can a Scala compiler plugin transform the autogenerated accessor methods of scala case classes?
- Using an "or" operator with an Int in Scala
- Operator < doesn't seem to support "Any" type How to fix it?
- Is there a way of publishing Akka actors with Mina?
- What's the difference between Erlang Actors, Scala Actors and the theoretical concept "Actor"?
- What does !# (reversed shebang) means?
- What's the difference between self-type `this: T =>` and `this: T`?
- Why does Future.onSuccess require a partial function
- Scala - return a Boolean that is neither True or False
- Spark Scala Window extend result until the end
- Limiting recursion depth in Scala
- Scala- Calculating total time from timestamps for a column value
- How to declare in scala a default param in a method of an implicit class