OPTIONS http://localhost:9000/api/chat/ 404 (Not Found) XMLHttpRequest cannot load http://localhost:9000/api/chat/. Response for preflight has invalid HTTP status code 404
Asked
Active
Viewed 301 times
1
-
Can not find dependencies for CROSSFilter play Framework. Not working this import: 'import play.filters.cors.CORSFilter;' Please help find MAVEN dependency – Vitaliy Denys Mar 23 '17 at 23:08
1 Answers
3
https://www.playframework.com/documentation/2.5.x/CorsFilter has details on enabling CORS for Play (which is Lagom is built on). To handle the OPTIONS
you may need to do something like:
.withAutoAcl(true)
.withServiceAcls(
ServiceAcl.methodAndPath(Method.OPTIONS, "/foo")
)
https://groups.google.com/forum/#!msg/lagom-framework/dtYN_1Ds4SQ/gT-BGPuCAQAJ is a lagom-framework list discussion thread with more details.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests has an explanation of why your browser is sending an OPTIONS
request to begin with.
The metadata for the current exact maven artifact which provides CORS for Play is this:
<metadata>
<groupId>com.typesafe.play</groupId>
<artifactId>filters-helpers_2.12</artifactId>
<versioning>
<latest>2.6.0-M2</latest>
<release>2.6.0-M2</release>
<versions>
<version>2.6.0-M1</version>
<version>2.6.0-M2</version>
</versions>
<lastUpdated>20170310220437</lastUpdated>
</versioning>
</metadata>

sideshowbarker
- 81,827
- 26
- 193
- 197
-
1This is a great answer. We (some employees at lightbend) recently worked on an experiment and we needed CORS on a Lagom service. See https://github.com/ignasi35/lagom-pet-store/blob/master/pet/src/main/java/Filters.java (Filters.java _must be_ in the default package) and https://github.com/ignasi35/lagom-pet-store/blob/master/build.sbt#L18 is required to import Play's filters. – ignasi35 Mar 22 '17 at 13:08
-
Can not find dependencies for CROSSFilter play Framework. Not working this import: 'import play.filters.cors.CORSFilter;' Please help find MAVEN dependency – Vitaliy Denys Mar 23 '17 at 22:32
-