Define CORS in Lagom framework


I’m currently developing client(ReactJs) server(Java) web application.
I’m trying to configure my back-end to work with method type ‘OPTIONS’ with no success.
How can it be done?


Have you taken a look at the Lagom recipe for CORS? It has both Java and Scala examples.

Thanks for the quick response.

yes, I saw the example.
The ‘Options’ request defined in a specific service impl, but lagom’s gateway blocks the request before it reaches the service api.

Try two things:

  • Test a CORS HTTP request directly to the service rather than the gateway. Lagom should display the port assigned to the service when you start dev mode.
  • Call withAutoAcl(true) in the service api and see it that enables you to make CORS requests through the gateway.


I found the problem, in the application.conf I changed pathPrefixes = ["/api"] to pathPrefixes = ["/"] and
in my service impl I added withServiceAcls(
ServiceAcl.methodAndPath(Method.OPTIONS, “/.*”)
with general path prefix and now it works.

Thank you,