From 904165860937ce94b6a515b4169465ecdddb6051 Mon Sep 17 00:00:00 2001 From: Facundo Giuliani Date: Mon, 28 Aug 2023 14:48:44 -0300 Subject: [PATCH] feat(SDK-88): Custom bridge URL --- lib/index.ts | 7 ++++++- lib/types.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index dc5dcadd..503e64cb 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -14,7 +14,7 @@ import { RichtextResolver } from "storyblok-js-client"; let richTextResolver; -const bridgeLatest = "https://app.storyblok.com/f/storyblok-v2-latest.js"; +let bridgeLatest = "https://app.storyblok.com/f/storyblok-v2-latest.js"; export const useStoryblokBridge = < T extends StoryblokComponentType = any @@ -62,6 +62,7 @@ export const storyblokInit = (pluginOptions: SbSDKOptions = {}) => { use = [], apiOptions = {}, richText = {}, + bridgeUrl } = pluginOptions; apiOptions.accessToken = apiOptions.accessToken || accessToken; @@ -74,6 +75,10 @@ export const storyblokInit = (pluginOptions: SbSDKOptions = {}) => { result = { ...result, ...pluginFactory(options) }; }); + if (bridgeUrl) { + bridgeLatest = bridgeUrl; + } + /* ** Load bridge if you are on the Visual Editor ** For more security: https://www.storyblok.com/faq/how-to-verify-the-preview-query-parameters-of-the-visual-editor diff --git a/lib/types.ts b/lib/types.ts index 3f3b611e..49d76718 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -35,6 +35,7 @@ export interface SbSDKOptions { use?: any[]; apiOptions?: ISbConfig; richText?: SbRichTextOptions; + bridgeUrl?: string; } export interface ISbEventPayload = any> {