Comments (7)
Thanks @jamespohalloran for looking into this. I think I have slightly more understanding now. Your API does not have auth for the server side build so me switching to the createClient
as opposed to createLocalClient
causes it to break as it was trying to get a token which uses localStorage on the client side. Instead you run a local server to read the content locally on build.
It might be an idea to check if you are in a browser environment before the call to make it clearer to new people.
from tina-cloud-starter.
Hey @MightySCollins, I can speak to part of this!
Also I notice the usage of createLocalClient for example at https://github.com/tinacms/tina-cloud-starter/blob/main/pages/posts/%5Bfilename%5D.tsx#L41 and https://github.com/tinacms/tina-cloud-starter/blob/main/pages/index.tsx#L45 which ignores the NEXT_PUBLIC_USE_LOCAL_CLIENT option. Should this not just be createClient()?
The reason that the local client is always used within getStaticProps, is so that we can always use local files to statically build your production site.
The Tina Cloud server currently requires a logged-in user session, so it is only used in edit-mode (when your editors are logged in).
from tina-cloud-starter.
Was the ReferenceError: localStorage is not defined
popping up when using the Tina Cloud Client within getStaticProps
?
I will add that having a long-lived token for accessing the Tina Cloud API (that could be used at build-time) is something we've discussed, but aren't ready for yet.
from tina-cloud-starter.
It might be an idea to check if you are in a browser environment before the call to make it clearer to new people.
Yep! that's a great idea. I think this might be a common thing that users may run into when using the client.
from tina-cloud-starter.
@jamespohalloran Just had a thought... Does this mean that TinaCMS wont work with GCP if you use revalidate
? We have pages which pull from another API but when they revalidate hourly the tina graphql server is not running at 4001 as it was only done on the build step.
from tina-cloud-starter.
I haven't used GCP, so let me know if I'm misunderstanding your use case. It sounds like the pages that you're referring to are using SSR, to pull content from another API, and then are cached with GCP?
Right now, any pages that use Tina Cloud for their content need to be built statically when the local graphql server is still available (at build-time). If the pages being rebuilt with revalidate
are separate from your pages talking to Tina Cloud, you could mix/match static pages & SSR pages.
Curious to hear more about your use case though, would the static-only restriction would be a dealbreaker for you?
from tina-cloud-starter.
Sorry my phone tried to help. I meant to type getStaticProps
GSP. Lets say I have a product page which contains some static information from Tina Cloud but I also want to pull the latest product price I would add in revalidate
so Next.JS will invalidate the props over time. I also might have the list of products are really long, dynamic and constantly changing so I would not want to use getStaticPaths
but have Next.JS fire the requests when a user requests that product.
We even have use cases on sections like the homepage where we display popular products again with revalidate. Unfortunately Next.JS does not let you mix and match on the same page. Now I could run a local build server firewalled and have the app call that but its quite a bit of overhead and I assume the cli tool is not really optimised for production.
from tina-cloud-starter.
Related Issues (20)
- Description and readme HOT 8
- bug: template select shows for collections with no templates HOT 3
- Remove "edit this site" link from starter sidebar HOT 5
- Windows / Investigation: User using WSL2 was served OLD packages when using the starter for the first time. HOT 1
- Light/dark theme caching issue HOT 3
- quick start guide "Edit with Tina"-button missing HOT 1
- UX: Inform users they need to setup a media manager
- A way to fetch all the fields in all the blocks in a page? HOT 4
- 404 when website is hard refreshed, but internal route works as expected HOT 8
- Admin page is confusing HOT 1
- Bump `tina-cloud-starter` and swap out `pages/admin/[...slug].tsx`
- Creating a post from Vercel results in an error
- Reduce size of admin page bundle HOT 2
- How to sort results based on fields? HOT 1
- Can't import the named export 'AggregateError' from non EcmaScript module
- Clicks not registered in CMS list HOT 1
- Setting defaultValue results an error when trying to edit new list item HOT 2
- Subfolders for pages not supported? HOT 1
- Hero Image does not render on Vercel HOT 4
- Root path broken when deployed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tina-cloud-starter.