@@ -21,13 +21,17 @@ 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
28
. option ( "simple-index" , {
29
29
describe : "Use a simplified view for the server directory listing" ,
30
30
default : false ,
31
+
32
+ } )
33
+ . option ( "proxy" , {
34
+ describe : "Whether or not to use a configured proxy" ,
31
35
type : "boolean"
32
36
} )
33
37
. option ( "accept-remote-connections" , {
@@ -84,7 +88,7 @@ serve.handler = async function(argv) {
84
88
let changePortIfInUse = false ;
85
89
86
90
if ( ! port && tree . server && tree . server . settings ) {
87
- if ( argv . h2 ) {
91
+ if ( argv . h2 || argv . proxy ) {
88
92
port = tree . server . settings . httpsPort ;
89
93
} else {
90
94
port = tree . server . settings . httpPort ;
@@ -93,22 +97,32 @@ serve.handler = async function(argv) {
93
97
94
98
if ( ! port ) {
95
99
changePortIfInUse = true ; // only change if port isn't explicitly set
96
- if ( argv . h2 ) {
100
+ if ( argv . h2 || argv . proxy ) {
97
101
port = 8443 ;
98
102
} else {
99
103
port = 8080 ;
100
104
}
101
105
}
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
+ }
102
114
103
115
const serverConfig = {
104
116
port,
105
117
changePortIfInUse,
106
- h2 : argv . h2 ,
118
+ h2 : argv . h2 || argv . proxy ,
119
+ useProxy : argv . proxy ,
107
120
simpleIndex : ! ! argv . simpleIndex ,
108
121
acceptRemoteConnections : ! ! argv . acceptRemoteConnections ,
109
122
cert : argv . h2 ? argv . cert : undefined ,
110
123
key : argv . h2 ? argv . key : undefined ,
111
- sendSAPTargetCSP : ! ! argv . sapCspPolicies
124
+ sendSAPTargetCSP : ! ! argv . sapCspPolicies ,
125
+ cdnUrl
112
126
} ;
113
127
114
128
if ( serverConfig . h2 ) {
0 commit comments