@@ -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" , {
@@ -72,7 +76,7 @@ serve.handler = async function(argv) {
72
76
let changePortIfInUse = false ;
73
77
74
78
if ( ! port && tree . server && tree . server . settings ) {
75
- if ( argv . h2 ) {
79
+ if ( argv . h2 || argv . proxy ) {
76
80
port = tree . server . settings . httpsPort ;
77
81
} else {
78
82
port = tree . server . settings . httpPort ;
@@ -81,22 +85,32 @@ serve.handler = async function(argv) {
81
85
82
86
if ( ! port ) {
83
87
changePortIfInUse = true ; // only change if port isn't explicitly set
84
- if ( argv . h2 ) {
88
+ if ( argv . h2 || argv . proxy ) {
85
89
port = 8443 ;
86
90
} else {
87
91
port = 8080 ;
88
92
}
89
93
}
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
+ }
90
102
91
103
const serverConfig = {
92
104
port,
93
105
changePortIfInUse,
94
- h2 : argv . h2 ,
106
+ h2 : argv . h2 || argv . proxy ,
107
+ useProxy : argv . proxy ,
95
108
simpleIndex : ! ! argv . simpleIndex ,
96
109
acceptRemoteConnections : ! ! argv . acceptRemoteConnections ,
97
110
cert : argv . h2 ? argv . cert : undefined ,
98
111
key : argv . h2 ? argv . key : undefined ,
99
- sendSAPTargetCSP : ! ! argv . sapCspPolicies
112
+ sendSAPTargetCSP : ! ! argv . sapCspPolicies ,
113
+ cdnUrl
100
114
} ;
101
115
102
116
if ( serverConfig . h2 ) {
0 commit comments