Skip to content

Commit

Permalink
Merge pull request #365 from storyblok/SDK-88-custom-bridge-url
Browse files Browse the repository at this point in the history
feat(SDK-88): Custom bridge URL
  • Loading branch information
alexjoverm authored Aug 29, 2023
2 parents 924d559 + 9041658 commit 146e83e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> = any
Expand Down Expand Up @@ -62,6 +62,7 @@ export const storyblokInit = (pluginOptions: SbSDKOptions = {}) => {
use = [],
apiOptions = {},
richText = {},
bridgeUrl
} = pluginOptions;

apiOptions.accessToken = apiOptions.accessToken || accessToken;
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface SbSDKOptions {
use?: any[];
apiOptions?: ISbConfig;
richText?: SbRichTextOptions;
bridgeUrl?: string;
}

export interface ISbEventPayload<S extends ISbComponentType<string> = any> {
Expand Down

0 comments on commit 146e83e

Please sign in to comment.