diff --git a/cli/index.ts b/cli/index.ts index 5ecb7e65..a82387e7 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -21,7 +21,7 @@ type Options = { output?: string; title?: string; templateFileName?: string; - redocOptions?: object; + redocOptions?: any; }; const BUNDLES_DIR = dirname(require.resolve('redoc')); @@ -200,7 +200,9 @@ async function getPageHTML( let redocStandaloneSrc; if (ssr) { console.log('Prerendering docs'); - const store = await createStore(spec, pathToSpec, redocOptions); + + const specUrl = redocOptions.specUrl || (isURL(pathToSpec) ? pathToSpec : undefined); + const store = await createStore(spec, specUrl, redocOptions); const sheet = new ServerStyleSheet(); html = renderToString(sheet.collectStyles(React.createElement(Redoc, { store }))); css = sheet.getStyleTags(); @@ -282,3 +284,7 @@ function debounce(callback: Function, time: number) { }, time); }; } + +function isURL(str: string): boolean { + return /^(https?:)\/\//m.test(str); +}