-
Notifications
You must be signed in to change notification settings - Fork 8
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
Live Preview editor not working: Uncaught SyntaxError: "undefined" is not valid JSON #62
Comments
@alexjoverm any ideas why this might be happening? |
Very interesting issue @studiolathe! Judging by the error you're getting, seems like the issue it's at Storyblok Bridge level, so it's possible there is an issue there. That'd explain that you're also having the issue regardless on the SDK version. Is it possible for you to share something reproducible? A Stackblitz link would be very appreciated, so @Dawntraoz and I can investigate |
Hi @alexjoverm Thanks so much for getting back to me! I have spent quite a bit of time stepping back through old commits to try and find if something changed that would be triggering this bug and I think I have found the culprit! So... we were previously making all requests with the Preview access token and setting the request version to "Draft", see example below:
But it seemed we facing some caching issues with our Netlify builds so we switched to using the Public access token and updated all requests to I have now reverted all requests to use Do we know why the published version might be causing this and what is best practice for making in requests in a production site, should we use the Preview or Public token? I have added the nuxt.config.js
package.json (note this is working with
pages/index.vue
Please let me know your thoughts on best approach and if theres any improvements we can be making to the config? Thanks in advance! |
Hi, any progress on this issue? I've got the same scenario where using the Public key causes the above mentioned error in the live preview. Edit; |
@frans-vectra I am doing the same. I have the access token in env. I don't think there is a solution to have two different tokens so I guess the only option is to use the same key for both preview and live. @Dawntraoz are we missing something? I had a discussion today with my team and the only option we have is to obscure all the request to a server api middleware that proxies the requests. Not ideal! |
Hi folks @studiolathe, @frans-vectr, @SebbeJohansson, I think I may have found what is happening after double-checking your issue. The idea behind the But as you're using the same site for previewing and publishing the content, then you will need to use the asyncData: async (context) => {
const storyblokApi = useStoryblokApi();
// This is how we get that we are inside the Storyblok space:
const version =
context.query._storyblok || context.isDev ? 'draft' : 'published';
const { data } = await storyblokApi.get("cdn/stories/home", {
version,
});
return { story: data.story };
}, I hope this clarifies what is happening. Let me know if it works in your cases and if you think it will be worth it to add it to the Readme 💜 |
@Dawntraoz In my case, that doesn't fully fix our issue. Since we want to limit what actual Not sure if this is off-topic for this issue, but is there any documentation for handling "obscuring" the storyblok calls so that they are not shown on the client? Both for |
@SebbeJohansson I think you're right. That should not be part of this issue since the Visual Editor works. Maybe it's better to open a "question" tag issue and we can discuss it there 🚀 |
@Dawntraoz Im not sure if you meant in the general repo, or on here. I made it here since I need a suggestion specifically for nuxt2 (since this is a work question 😉). |
Has anyone had this problem occur for certain blocks on the page but not all of them? We are fetching the |
Hi there
I am using
storyblok-nuxt-2@^1.0.2
with Nuxt 2 (^2.15.8
) and the Live Preview editor (V2) is no longer working (when it previously was). When inspecting the console inside the Storyblok editor I noticed I am receiving the below error on every click inside the preview:On inspection of the rendered component HTML elements and it seems I am getting
undefined
on thedata-blok-c
anddata-blok-uid
attributes on all of the Storyblok rendered components:For further context, see the
nuxt.config.js
and page components:For additional context the preview was working and I have multiple projects using the same setup with no issues and inspecting the rendered elements displays the data attributes being rendered with Storyblok data..
Is this an issue related to my setup, the
StoryblokComponent
or withstoryblok-v2-latest.js
.FYI I have tested with the latest
storyblok-nuxt-2@^1.0.2
and the issues persists.Any help would be greatly appreciated!
Thanks in advance.
The text was updated successfully, but these errors were encountered: