-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sandbox): allow the sandbox to load plugins when running locally #367
base: main
Are you sure you want to change the base?
fix(sandbox): allow the sandbox to load plugins when running locally #367
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
host === 'plugin-sandbox.storyblok.com' | ||
? 'https://plugin-sandbox.storyblok.com' | ||
: 'https://app.storyblok.com' | ||
allowAllOrigins === true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would extract this for better code readability.
Thank you for suggesting this change @demetriusfeijoo. I am wondering if we should add In any case, we need to add this to the docs explaining the usage of this new config parameter. What do you think? |
What if we even have something like this? useFieldPlugin({
target: 'https://something-else.com'
}) and if target is not provided, it falls back the the previous implementation (either sandbox or the production according to the host parameter) |
@eunjae-lee, totally agree with your suggestion. @demetriusfeijoo However please deprioritize this PR for now due to the cycle commitment. |
Thanks for your reviews on this one @BibiSebi @eunjae-lee. 🚀 I thought about letting the developer use the wildcard (*) so, for example, even if the sandbox is running locally in a different port than When we return to this PR (after the cycle finishes) we may discuss having a third approach which would be your suggestion @eunjae-lee, but allowing also the wildcard, IDK. Something like:
If it's set to Just another idea that doesn't need to be handled now as we're at the begin of our cycle. |
I just realized that the Sandbox preview also doesn't work due to the same issue. |
What?
Add the
allowAllOrigins
option to thecreateFieldPlugin
function.Why?
JIRA: EXT-2258
It allows our
demo
package (or any other plugin created by other developers) to be loaded in a local running instance of the Sandbox.How to reproduce?
From the
main
branch run:Then, this error should appear in your console:
![image](https://private-user-images.githubusercontent.com/1240591/309423105-6397a3b1-efe0-4341-8c3f-65dda9a4ba8c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNjQxMjYsIm5iZiI6MTcxOTI2MzgyNiwicGF0aCI6Ii8xMjQwNTkxLzMwOTQyMzEwNS02Mzk3YTNiMS1lZmUwLTQzNDEtOGMzZi02NWRkYTlhNGJhOGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjRUMjExNzA2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjQzOTM3YjJjYjYzM2JiZDIwNGUxNGUwM2QzNDA1NGIxMWIyODczZTBjZTEzYTQ1ZThjNzkzZDhkY2IwNjI1OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.XIIH2zf5RmRRj_-0E_Xmr_b_xbx6-IT-O3e5s-ToCk8)
and the demo plugin should not be loaded:
![image](https://private-user-images.githubusercontent.com/1240591/309423285-e2d963d4-1687-4471-bcd6-c1cefdfb3376.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNjQxMjYsIm5iZiI6MTcxOTI2MzgyNiwicGF0aCI6Ii8xMjQwNTkxLzMwOTQyMzI4NS1lMmQ5NjNkNC0xNjg3LTQ0NzEtYmNkNi1jMWNlZmRmYjMzNzYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjRUMjExNzA2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzkxMTA2MGYwYmYwOWY5ODQwYmJjZWNiMzMzMDhjOTZjNGY3MjJmNTg4MjJkNDZkMDBlNDZkOTRkMjBmNzJlOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.t6UVN5z9rBm_WGzESlj97if9HTaeXAoOX0jrmVu9Bd4)
How it should work after the change?
Now, from the task's branch, run these commands:
Then, no error should appear in your console:
![image](https://private-user-images.githubusercontent.com/1240591/309423873-6a843ba4-0866-4bfb-b9f2-b368014028dd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNjQxMjYsIm5iZiI6MTcxOTI2MzgyNiwicGF0aCI6Ii8xMjQwNTkxLzMwOTQyMzg3My02YTg0M2JhNC0wODY2LTRiZmItYjlmMi1iMzY4MDE0MDI4ZGQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjRUMjExNzA2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGI1M2JjYTdhNGI0MmVmZTgzMzBmNjE0ZTk0NjZmYjM1Y2E5NTNjNWMzNzkwYzliMTE3MGY1ZTk0NmZlNTc2MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.1kMWJYkfjDbeVC9qov-kOY8Ratmeaq87hNuoBdbOzrk)
and the demo plugin should be loaded:
![image](https://private-user-images.githubusercontent.com/1240591/309423840-308f7258-5a43-4d6d-b481-20a278bd8bbe.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNjQxMjYsIm5iZiI6MTcxOTI2MzgyNiwicGF0aCI6Ii8xMjQwNTkxLzMwOTQyMzg0MC0zMDhmNzI1OC01YTQzLTRkNmQtYjQ4MS0yMGEyNzhiZDhiYmUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjRUMjExNzA2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjJmYjMwNzBkMmIxN2U4YWNhMmFmMmQxZThkMjZhMmEwZmI2NTcyNWY2ZDFjMmNkMThiY2VkNzY2MDFlNGUyMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.B_KqOM1zZNMlvDUFGDcVcNBdLhBvYc4NaGHo419pLV0)
PS: The Vercel action is not running yet since it wasn't modified to consider the new path (
packages/sandbox
) and also the new project name (modified here) in its settings.