Code Monkey home page Code Monkey logo

Comments (3)

samlfair avatar samlfair commented on July 24, 2024 1

Hey @FrancoisLeclerc,

Thanks for posting this issue. Just FYI, for questions like this, you can always use the Prismic Community Forum. We monitor discussion on the forum more actively than on GitHub.

Unfortunately, there is no easy way to use a private repo with client-side routing. With Next projects, API requests are made client-side, so your API key will be exposed.

The only workaround would be to create your own API to proxy requests from your Next app to the Prismic API. More info in this article.

from nextjs-starter-prismic-multi-language.

pvpg avatar pvpg commented on July 24, 2024

Hello @FrancoisLeclerc. Thank you for letting us know about this and for sharing your solution.

Indeed, environment variables work correctly if you do not make those extra calls to Prismic on the client-side. As Sam said before, this is the only available option to make the toolbar work properly in Next.js.

The toolbar works like this; when it is active, it is always waiting or ‘listening’ to queries made to a Prismic endpoint from every page. This is how you get the documents for each displayed page and a link that redirects you to the correct document within the repository. This is not possible in Next as everything is done at build time. Static pages make no calls to Prismic. And that’s the reason why we built a method that makes these needed calls even when every page is already rendered. Being so, you have two options:

  1. If you don’t need to use the edit button, you can remove the functions pageToolbarDocs and homepageToolbarDocs prismicToolbarQueries.js file altogether. As their only function is to load queries used in the Toolbar, you can remove them without any problem.

  2. If you want to use the edit button: You’re going to have to expose the API token using the NEXT_PUBLIC variable name that you mentioned before. For the time being, these are the two feasible options.

You could also try and implement a proxy like the one Sam suggested. We hope this doesn’t complicate much your development process.

from nextjs-starter-prismic-multi-language.

FrancoisLeclerc avatar FrancoisLeclerc commented on July 24, 2024

Thank you for your help! I ended up removing them as it's not crucial for my use case.

from nextjs-starter-prismic-multi-language.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.