Window.prismic.endpoint is deprecated

Hi,

I follow this document to setup preview in my ruby web application - Prismic’s documentation for PHP, Laravel, Java, .NET, and Ruby has moved to GitHub - Prismic.

The Prismic toolbar do not appear and I saw below message in console.

What should I follow between the console log and Prismic document?

1 Like

I have replaced old script with the one from Browser pop-up and the preview is working.

I think you should update the Javascript in dashboard /settings/previews/

2 Likes

@renaud it looks like the docs still aren’t up to date with this deprecation warning. It’s very confusing, particularly since it shows a link to get the ‘complete documentation’, which isn’t complete, and therefore not helpful.

Hey Alan, welcome to the Prismic forum.

Thank you very much for making us aware of this. I'll make sure this section of the documentation is clearer.

For now, you need to check the preview script in your repo for new=true and if you don't see it, just ask us to activate the New toolbar for you here in the forum:

We've updated the documentation to display the correct version of the script and it's now available in all repositories.

Now, If you still use it in your project and see this error, go to your repository's Settings > Previews and Include the Prismic Toolbar javascript file in your project.

Thanks a lot!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Hi Pau, can you activate this for us?

Hello @tim9, we've merged this update into all the repositories. You should be able to see it and change it in your code. I've updated the solution of this thread to reflect this information.

Let us know if you have any questions.

Thanks

Hi @Pau , we don't include this anywhere in our code. We have the following prismic packages included in our gatsby project.

"@prismicio/client": "^4.0.0",
"gatsby-source-prismic-graphql": "^3.5.0",
"prismic-dom": "^2.2.4",
"prismic-javascript": "^2.7.0",
"prismic-reactjs": "^1.3.0",

This script is inserted into every page of your site. The deprecated version, which throws that error, looks like this:

<script>
  window.prismic = {
    endpoint: 'https://your-repo-name.cdn.prismic.io/api/v2'
  };
</script>
<script type="text/javascript" src="https://static.cdn.prismic.io/prismic.min.js"></script>

The current one looks like this:

<script async defer src="https://static.cdn.prismic.io/prismic.js?new=true&repo=your-repo-name"></script>

@Pau , I see it in the source code, what I mean is that one of the prismic packages is inserting that script. Can you let me know which package I need to upgrade to get the new version of the the script?

@Pau , I see this code is being injected by gatsby-source-prismic-graphql. I'm guessing that means we need to migrate to gatsby-source-prismic for previews to work? Is there any way to get previews working in the interim without migrating? When I add the current script to the page, I get a new warning about 2 integration scripts being included.

Hey @tim9, I didn't realize you were using gatsby-source-prismic-graphql. That's why you weren't seeing the script cause it adds it automatically.

Yes, you'll need to migrate. We are no longer supporting that plugin. We have migration guides and full documentation for gatsby-source-prismic.

Please reach out to us if you find any trouble along the way.