@@ -21,10 +21,14 @@ serve.builder = function(cli) {
21
21
type : "string"
22
22
} )
23
23
. 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" ,
25
25
default : false ,
26
26
type : "boolean"
27
27
} )
28
+ . option ( "proxy" , {
29
+ describe : "Whether or not to use a configured proxy" ,
30
+ type : "boolean"
31
+ } )
28
32
. option ( "accept-remote-connections" , {
29
33
describe : "Accept remote connections. By default the server only accepts connections from localhost" ,
30
34
default : false ,
@@ -63,17 +67,27 @@ serve.handler = function(argv) {
63
67
translatorName : argv . translator ,
64
68
configPath : argv . config
65
69
} ) . 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
+ }
66
78
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 ,
68
80
changePortIfInUse : argv . port === undefined , // only change if port isn't explicitly set
69
81
h2 : argv . h2 ,
82
+ useProxy : argv . proxy ,
70
83
acceptRemoteConnections : ! ! argv . acceptRemoteConnections ,
71
84
cert : argv . h2 ? argv . cert : undefined ,
72
85
key : argv . h2 ? argv . key : undefined ,
73
- sendSAPTargetCSP : ! ! argv . sapCspPolicies
86
+ sendSAPTargetCSP : ! ! argv . sapCspPolicies ,
87
+ cdnUrl
74
88
} ;
75
89
76
- if ( ! serverConfig . h2 ) {
90
+ if ( ! serverConfig . h2 && ! serverConfig . useProxy ) {
77
91
return { serverConfig, tree} ;
78
92
} else {
79
93
return ui5Server . sslUtil . getSslCertificate ( serverConfig . key , serverConfig . cert ) . then ( ( { key, cert} ) => {
@@ -83,8 +97,7 @@ serve.handler = function(argv) {
83
97
} ) ;
84
98
}
85
99
} ) . 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} ) {
88
101
let browserUrl = protocol + "://localhost:" + port ;
89
102
console . log ( "Server started" ) ;
90
103
console . log ( "URL: " + browserUrl ) ;
0 commit comments