@@ -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" , {
@@ -72,7 +76,7 @@ serve.handler = async function(argv) {
7276 let changePortIfInUse = false ;
7377
7478 if ( ! port && tree . server && tree . server . settings ) {
75- if ( argv . h2 ) {
79+ if ( argv . h2 || argv . proxy ) {
7680 port = tree . server . settings . httpsPort ;
7781 } else {
7882 port = tree . server . settings . httpPort ;
@@ -81,22 +85,32 @@ serve.handler = async function(argv) {
8185
8286 if ( ! port ) {
8387 changePortIfInUse = true ; // only change if port isn't explicitly set
84- if ( argv . h2 ) {
88+ if ( argv . h2 || argv . proxy ) {
8589 port = 8443 ;
8690 } else {
8791 port = 8080 ;
8892 }
8993 }
94+ let cdnUrl ;
95+ if ( tree . server && tree . server . cdnUrl ) {
96+ if ( tree . specVersion !== "1.1a" ) {
97+ throw new Error ( `Server configuration "cdnUrl" can only be used with specification version "1.1a". ` +
98+ `But project ${ tree . metadata . name } defines "${ tree . specVersion } ".` ) ;
99+ }
100+ cdnUrl = tree . server . cdnUrl ;
101+ }
90102
91103 const serverConfig = {
92104 port,
93105 changePortIfInUse,
94- h2 : argv . h2 ,
106+ h2 : argv . h2 || argv . proxy ,
107+ useProxy : argv . proxy ,
95108 simpleIndex : ! ! argv . simpleIndex ,
96109 acceptRemoteConnections : ! ! argv . acceptRemoteConnections ,
97110 cert : argv . h2 ? argv . cert : undefined ,
98111 key : argv . h2 ? argv . key : undefined ,
99- sendSAPTargetCSP : ! ! argv . sapCspPolicies
112+ sendSAPTargetCSP : ! ! argv . sapCspPolicies ,
113+ cdnUrl
100114 } ;
101115
102116 if ( serverConfig . h2 ) {
0 commit comments