UNPKG

@sitecore-jss/sitecore-jss-rendering-host

Version:

This module is provided as a part of Sitecore JavaScript Rendering SDK (JSS). It contains the rendering host implementation.

19 lines (18 loc) 746 B
import ngrok from 'ngrok'; /** * @param {string} renderHostname * @param {Ngrok.Options} options */ export function startRenderHostTunnel(renderHostname, options = { port: 80, proto: 'http', quiet: false }) { if (!renderHostname) { throw new Error('Unable to start render host tunnel as no hostname for the rendering host was specified.'); } const rewriteHost = `${renderHostname}:${options.port}`; const finalOptions = Object.assign(Object.assign({}, options), { host_header: 'rewrite', addr: rewriteHost }); return ngrok.connect(finalOptions).then((url) => { if (!options.quiet) { console.log(`Tunnel started, forwarding '${url}' to '${rewriteHost}'`); } return url; }); }