Hosting static HTML in a Play! app on CloudFront

狂风中的少年 提交于 2019-12-06 10:51:45

I've used the following in my conf/routes file to do this:

# Map static resources from the /app/public folder to the /public path
#{if play.Play.mode.isDev()}
    GET     /public/                        staticDir:public
#{/}
#{else}
    GET     d2iu8jbjgczc8x.cloudfront.net/public  staticDir:public
    GET     /public/                              staticDir:public
#{/}

Then you just reference the static assets the normal way and the URLs will use the CloudFront server (in Prod mode).

Could never get this to work in Play 2.x.

GET     /public/      staticDir:public

What worked for me is something like this.

GET  /somefile.html   controllers.Assets.at(path="/public", file="somefile.html")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!