且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Play中托管静态HTML! CloudFront上的应用程序

更新时间:2023-10-11 12:31:46

我在我的conf/routes文件中使用了以下内容:

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
#{/}

然后,您仅以常规方式引用静态资产,URL将使用CloudFront服务器(处于Prod模式).

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