field-plugin
field-plugin copied to clipboard
Can't use Sandbox to show previews
Describe the bug
Both the sandbox and editor (in Storyblok) has an input field where you can specify the URL of the field plugin:
But the field plugin is now refusing to post message to any other host than app.storyblok.com
, meaning that you can't display previews anymore.
For example, the code block field plugin uses an older version of the library, which means that you can preview it with a Vercel preview:
https://plugin-sandbox.storyblok.com/field-plugin?url=https%3A%2F%2Fstoryblok-code-block.vercel.app%2F
But this doesn't work with the latest version of the library.
To Reproduce
Try to use the sandbox or editor with any field plugin on the most recent version:
- If you're not serving in dev mode, you won't be able to use the sandbox
- If you're not serving in production mode, you won't be able to use the editor
Or try to use the sandbox in local development mode:
See https://plugin-sandbox.storyblok.com/field-plugin?url=https%3A%2F%2Fstoryblok-code-block.vercel.app%2F
Expected behavior
For previews to work again, as outlined in the docs: https://www.storyblok.com/docs/plugins/field-plugins/continuous-delivery#preview-urls
Cause
This line:
// ToDo: In development we need to load localhost:3300
const origin =
typeof targetOrigin === 'string'
? targetOrigin
: host === 'plugin-sandbox.storyblok.com'
? 'https://plugin-sandbox.storyblok.com'
: 'https://app.storyblok.com'