@@ -21,13 +21,17 @@ serve.builder = function(cli) {
2121 type : "string"
2222 } )
2323 . option ( "h2" , {
24- describe : "Shortcut for enabling the HTTP/2 protocol for the web server" ,
24+ describe : "Enables HTTP/2 and HTTPS protocol for the web server" ,
2525 default : false ,
2626 type : "boolean"
2727 } )
2828 . option ( "simple-index" , {
2929 describe : "Use a simplified view for the server directory listing" ,
3030 default : false ,
31+
32+ } )
33+ . option ( "proxy" , {
34+ describe : "Whether or not to use a configured proxy" ,
3135 type : "boolean"
3236 } )
3337 . option ( "accept-remote-connections" , {
@@ -84,7 +88,7 @@ serve.handler = async function(argv) {
8488 let changePortIfInUse = false ;
8589
8690 if ( ! port && tree . server && tree . server . settings ) {
87- if ( argv . h2 ) {
91+ if ( argv . h2 || argv . proxy ) {
8892 port = tree . server . settings . httpsPort ;
8993 } else {
9094 port = tree . server . settings . httpPort ;
@@ -93,22 +97,32 @@ serve.handler = async function(argv) {
9397
9498 if ( ! port ) {
9599 changePortIfInUse = true ; // only change if port isn't explicitly set
96- if ( argv . h2 ) {
100+ if ( argv . h2 || argv . proxy ) {
97101 port = 8443 ;
98102 } else {
99103 port = 8080 ;
100104 }
101105 }
106+ let cdnUrl ;
107+ if ( tree . server && tree . server . cdnUrl ) {
108+ if ( tree . specVersion !== "1.1a" ) {
109+ throw new Error ( `Server configuration "cdnUrl" can only be used with specification version "1.1a". ` +
110+ `But project ${ tree . metadata . name } defines "${ tree . specVersion } ".` ) ;
111+ }
112+ cdnUrl = tree . server . cdnUrl ;
113+ }
102114
103115 const serverConfig = {
104116 port,
105117 changePortIfInUse,
106- h2 : argv . h2 ,
118+ h2 : argv . h2 || argv . proxy ,
119+ useProxy : argv . proxy ,
107120 simpleIndex : ! ! argv . simpleIndex ,
108121 acceptRemoteConnections : ! ! argv . acceptRemoteConnections ,
109122 cert : argv . h2 ? argv . cert : undefined ,
110123 key : argv . h2 ? argv . key : undefined ,
111- sendSAPTargetCSP : ! ! argv . sapCspPolicies
124+ sendSAPTargetCSP : ! ! argv . sapCspPolicies ,
125+ cdnUrl
112126 } ;
113127
114128 if ( serverConfig . h2 ) {
0 commit comments