@@ -195,6 +195,8 @@ export function resolveServiceBuildInfo(service, name, opts: ServiceOptions) {
195195 public : isPublic ,
196196 port,
197197 env,
198+ protocol,
199+ ssl,
198200 __autobuild,
199201 __compile,
200202 } = resolvedWithoutSource
@@ -211,11 +213,32 @@ export function resolveServiceBuildInfo(service, name, opts: ServiceOptions) {
211213 : fullFile
212214 : null // Reference correctly from build Electron application
213215
216+ // Resolve SSL certificate paths
217+ let resolvedSSL = undefined
218+ if ( ssl ?. key && ssl ?. cert ) {
219+ const keyPath = resolvePath ( root , ssl . key )
220+ const certPath = resolvePath ( root , ssl . cert )
221+
222+ // Only include SSL if both files exist
223+ if ( existsSync ( keyPath ) && existsSync ( certPath ) ) {
224+ resolvedSSL = {
225+ key : keyPath ,
226+ cert : certPath
227+ }
228+ } else {
229+ logger . warn ( `SSL configuration provided but certificate files not found:` )
230+ if ( ! existsSync ( keyPath ) ) logger . warn ( ` - Key file not found: ${ keyPath } ` )
231+ if ( ! existsSync ( certPath ) ) logger . warn ( ` - Cert file not found: ${ certPath } ` )
232+ }
233+ }
234+
214235 return {
215236 src,
216237 url,
217238 build,
218239 env,
240+ protocol,
241+ ssl : resolvedSSL ,
219242 base : base && resolvePath ( root , base ) ,
220243 filepath : file ,
221244
@@ -234,7 +257,7 @@ function getLocalUrl(url) {
234257
235258async function getServiceUrl ( service ) {
236259 const resolved = resolveServiceConfiguration ( service )
237- const { url, port, src } = resolved
260+ const { url, port, src, ssl , protocol } = resolved
238261
239262 if ( ! src ) return url // Cannot generate URL without source file
240263
@@ -244,6 +267,12 @@ async function getServiceUrl(service) {
244267 if ( _url ) {
245268 const resolvedPort = port || ( await getFreePorts ( 1 ) ) [ 0 ]
246269 if ( ! _url . port ) _url . port = resolvedPort . toString ( ) // Use the specified port
270+
271+ // Auto-update protocol to https when SSL is configured
272+
273+ if ( protocol ) _url . protocol = protocol // Use custom protocol if provided
274+ else if ( ssl ?. key && ssl ?. cert ) _url . protocol = 'https:'
275+
247276 return _url . href
248277 }
249278
@@ -278,12 +307,14 @@ export async function resolveService(config, name, opts: ServiceOptions) {
278307 base,
279308 build,
280309 url,
310+ protocol,
311+ ssl,
281312 __src = src && resolve ( root , src ) ,
282313 __compile,
283314 __autobuild,
284315 } = resolvedForBuild
285316
286- resolvedForBuild . url = await getServiceUrl ( { src, url, port } )
317+ resolvedForBuild . url = await getServiceUrl ( { src, url, port, ssl , protocol } )
287318
288319 const isMobileTarget = isMobile ( target )
289320
@@ -303,6 +334,7 @@ export async function resolveService(config, name, opts: ServiceOptions) {
303334 base,
304335 build, // Build Info
305336 env : resolvedForBuild . env ,
337+ ssl : resolvedForBuild . ssl ,
306338 __src,
307339 __compile,
308340 __autobuild, // Flags
@@ -361,11 +393,18 @@ export async function start(
361393 // Get service-specific env variables
362394 const serviceEnv = config . env && typeof config . env === 'object' ? config . env : { }
363395
396+ // Add SSL certificate paths to environment if configured
397+ const sslEnv = config . ssl ? {
398+ SSL_KEY_PATH : config . ssl . key ,
399+ SSL_CERT_PATH : config . ssl . cert ,
400+ } : { }
401+
364402 // Share environment variables with the child process
365403 const env = {
366404 ...userEnv ,
367405 ...process . env ,
368406 ...serviceEnv ,
407+ ...sslEnv ,
369408 PORT : resolvedURL . port ,
370409 HOST : resolvedURL . hostname ,
371410 }
0 commit comments