Hello.
I use remote staging server to test my PWA application which is under development and based on Magento 2.3 Venia theme. I see Node generates devcert certificate automatically on application run. But it is not trusted by browsers of course. I have my own Lets encrypt certificate for staging domain and want to force using it for my application.
How can I do it? I found only instructions of how to specify custom cert files for Express.js app, but Magento 2 PWA studio is quite complex and I don't know where should I specify it.
Solved! Go to Solution.
In packages/package-name/.env :
MAGENTO_BUILDPACK_SECURE_HOST_SSL_KEY='path/to/file'
MAGENTO_BUILDPACK_SECURE_HOST_SSL_CERT='path/to/file'
In packages/package-name/webpack.config.js :
devServerConfig.provideSecureHost = {
subdomain: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SUBDOMAIN,
exactDomain: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_EXACT_DOMAIN,
addUniqueHash: !!validEnv.MAGENTO_BUILDPACK_SECURE_HOST_ADD_UNIQUE_HASH,
keyFile: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SSL_KEY,
certFile: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SSL_CERT};
In packages/pwa-buildpack/src/WebpackTools/PWADevServer.js :
devServerConfig.https = hostConf.certFile && hostConf.keyFile ? {
key: readFileSync(hostConf.keyFile, 'utf-8'),
cert: readFileSync(hostConf.certFile, 'utf-8') } : ssl;
In packages/package-name/.env :
MAGENTO_BUILDPACK_SECURE_HOST_SSL_KEY='path/to/file'
MAGENTO_BUILDPACK_SECURE_HOST_SSL_CERT='path/to/file'
In packages/package-name/webpack.config.js :
devServerConfig.provideSecureHost = {
subdomain: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SUBDOMAIN,
exactDomain: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_EXACT_DOMAIN,
addUniqueHash: !!validEnv.MAGENTO_BUILDPACK_SECURE_HOST_ADD_UNIQUE_HASH,
keyFile: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SSL_KEY,
certFile: validEnv.MAGENTO_BUILDPACK_SECURE_HOST_SSL_CERT};
In packages/pwa-buildpack/src/WebpackTools/PWADevServer.js :
devServerConfig.https = hostConf.certFile && hostConf.keyFile ? {
key: readFileSync(hostConf.keyFile, 'utf-8'),
cert: readFileSync(hostConf.certFile, 'utf-8') } : ssl;