Reputation: 2942
I am migrating our application from Play 2.3.x to 2.4.x. With the migration away from static routing, I apparently lose the ability to redirect to some assets. The application implements a tenant functionality which can be appended to the url (localhost:9000/Tenant/), which the redirects you to the login page with appropriate tenant set in the background. The default tenant (for development purposes) can be accessed by using no appendix to the url (localhost:9000/).
The issue is now that after setting the tenant, I redirect to the app/index.html using the following:
return redirect(query != null ? "app/index.html?" + query : "app/index.html");
The redirect works but unfortunately I get "Action not found for request 'GET /app/index.html'". I also can not access the asset if I manually redirect.
In the routes file of the application, the following route entry should correctly handle this redirect, am I wrong?
# Map static resources from the /public/app folder to the /app URL path
GET /app/*file controllers.Assets.at(path="/public/app", file)
The log unfortunately does not say anything special except for:
**** [TRACE] Http request received by netty: DefaultHttpRequest(chunked: false)
**** GET /app/index.html HTTP/1.1
**** Host: localhost:9000
**** Connection: keep-alive
**** Upgrade-Insecure-Requests: 1
**** User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
**** Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
**** Accept-Encoding: gzip, deflate, sdch
**** Accept-Language: en-US,en;q=0.8,de;q=0.6
**** Cookie: PLAY_SESSION="f2069c9ef539f8d3fe9d07327a3c65bd4a45cb79-MANDT=0B7ABE451F3441A5AB93799DBC8621EF" [play.core.server.netty.PlayDefaultUpstreamHandler]
**** [TRACE] Serving this request with: <function1> [play.core.server.netty.PlayDefaultUpstreamHandler]
**** [TRACE] Invoking action with request: GET /app/index.html [play.api.mvc.Action]
I saw in other cases [Play Framework Routes not working ] that people have received an error on console says which routes have been tried.
This worked in 2.3.x, but not anymore in 2.4.x. Am I missing anything?
Upvotes: 0
Views: 820
Reputation: 2942
I could resolve the issue:
I realized that while migrating, I was not following the migration guide properly for SbtWeb usage.
The whole configuration was missing the enablePlugins(...,SbtWeb) and I was missing sbt-gzip etc. Just be sure to properly follow the guide and compare the configuration to a newly created, fresh project. The latter helped a lot when looking for standard configurations that can easily get overseen when migrating.
Upvotes: 0