結局、本番環境で公開アセットから直接リソースを読み込む方法はわからなかったのですが、def vueappでMode.Dev以外の場合はAssets.atを呼び出すように修正したところ、目的の動作になりましたので、一応これで解決とします。
scala
1package controllers
2
3import com.mohiva.play.silhouette.api.actions.SecuredRequest
4import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
5import com.mohiva.play.silhouette.api.{LogoutEvent, Silhouette}
6import javax.inject.Inject
7import models.services.IndexRenderService
8import play.api.{Environment, Mode}
9import play.api.http.ContentTypes
10import play.api.i18n.I18nSupport
11import play.api.libs.ws.WSClient
12import play.api.mvc._
13import utils.auth.DefaultEnv
14
15import scala.concurrent.{ExecutionContext} //, Future}
16
17192021
22class ApplicationController @Inject() (
23 components: ControllerComponents,
24 silhouette: Silhouette[DefaultEnv],
25 environment: Environment,
26 ws: WSClient,
27 indexRenderService: IndexRenderService,
28 authInfoRepository: AuthInfoRepository,
29 myAssets: controllers.Assets
30)(implicit ec: ExecutionContext)
31 extends AbstractController(components)
32 with I18nSupport {
33
34 35
36 def vueapp(path: String) = silhouette.UserAwareAction.async { implicit req =>
37 environment.mode match {
38 case Mode.Dev =>
39 fetchWebpackServer(path)
40 case _ =>
41 //renderIndexPage()
42 myAssets.at(path = "/public/ui", "index.html")(req)
43 }
44 }
45
46 4849
50 def signOut = silhouette.SecuredAction.async {
51 implicit request: SecuredRequest[DefaultEnv, AnyContent] =>
52 silhouette.env.eventBus.publish(LogoutEvent(request.identity, request))
53 silhouette.env.authenticatorService.discard(request.authenticator, Ok)
54 }
55
56 58596061
62 private def fetchWebpackServer(
63 path: String
64 )(implicit request: RequestHeader) = {
65 ws.url(s"http://localhost:8080/$path").get().map { r =>
66 if (r.contentType.equalsIgnoreCase(HTML(Codec.utf_8))) {
67 val html = r.bodyAsBytes.utf8String
68 Ok(indexRenderService.setCsrfToken(html)).as(ContentTypes.HTML)
69 } else {
70 new Status(r.status)(r.bodyAsBytes).as(r.contentType)
71 }
72 }
73 }
74
75
76 ///** Renders index page by injecting CSRF token
77 // *
78 // * @param request HTTP request
79 // * @return
80 // */
81 //private def renderIndexPage()(implicit request: RequestHeader) = {
82 // Future.successful {
83 // val html = indexRenderService.render(
84 // Some(
85 // "Scala PlayFramework authentication and user management sample using Silhouette VueJs"
86 // )
87 // )
88 // Ok(html).as(ContentTypes.HTML)
89 // }
90 //}
91
92
93}
94
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。