@@ -21,10 +21,14 @@ 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 } )
28+ . option ( "proxy" , {
29+ describe : "Whether or not to use a configured proxy" ,
30+ type : "boolean"
31+ } )
2832 . option ( "accept-remote-connections" , {
2933 describe : "Accept remote connections. By default the server only accepts connections from localhost" ,
3034 default : false ,
@@ -63,17 +67,27 @@ serve.handler = function(argv) {
6367 translatorName : argv . translator ,
6468 configPath : argv . config
6569 } ) . then ( function ( tree ) {
70+ let cdnUrl ;
71+ if ( tree . server && tree . server . cdnUrl ) {
72+ if ( tree . specVersion !== "1.1a" ) {
73+ throw new Error ( `Server configuration "cdnUrl" can only be used with specification version "1.1a". ` +
74+ `But project ${ tree . metadata . name } defines "${ tree . specVersion } ".` ) ;
75+ }
76+ cdnUrl = tree . server . cdnUrl ;
77+ }
6678 const serverConfig = {
67- port : argv . port === undefined ? argv . h2 ? 8443 : 8080 : argv . port ,
79+ port : argv . port === undefined ? ( argv . h2 || argv . proxy ) ? 8443 : 8080 : argv . port ,
6880 changePortIfInUse : argv . port === undefined , // only change if port isn't explicitly set
6981 h2 : argv . h2 ,
82+ useProxy : argv . proxy ,
7083 acceptRemoteConnections : ! ! argv . acceptRemoteConnections ,
7184 cert : argv . h2 ? argv . cert : undefined ,
7285 key : argv . h2 ? argv . key : undefined ,
73- sendSAPTargetCSP : ! ! argv . sapCspPolicies
86+ sendSAPTargetCSP : ! ! argv . sapCspPolicies ,
87+ cdnUrl
7488 } ;
7589
76- if ( ! serverConfig . h2 ) {
90+ if ( ! serverConfig . h2 && ! serverConfig . useProxy ) {
7791 return { serverConfig, tree} ;
7892 } else {
7993 return ui5Server . sslUtil . getSslCertificate ( serverConfig . key , serverConfig . cert ) . then ( ( { key, cert} ) => {
@@ -83,8 +97,7 @@ serve.handler = function(argv) {
8397 } ) ;
8498 }
8599 } ) . then ( ( { serverConfig, tree} ) => {
86- return server . serve ( tree , serverConfig ) . then ( function ( { h2, port} ) {
87- const protocol = h2 ? "https" : "http" ;
100+ return server . serve ( tree , serverConfig ) . then ( function ( { protocol, port} ) {
88101 let browserUrl = protocol + "://localhost:" + port ;
89102 console . log ( "Server started" ) ;
90103 console . log ( "URL: " + browserUrl ) ;
0 commit comments