react-tweet: Tweet Not Found
I know there is already another issue for this #134 but they closed it without an actual resolution from the library itself. I can get the tweet to load on localhost:3000 just fine
However, when I am previewing it through a deployment branch, it just returns Tweet not found
I get no errors in my Vercel logs at all and nothing in the console and nothing in the network tab. This is currently stopping me from publishing some changes to my website.
So I decided to just push my changes to production and just tell my authors to not include tweets for the time being… However, I can now see errors in Vercel but all it is saying is
Error: Failed to get tweet data for tweet ID: 1556693648762437637
at getTweets (/var/task/.next/server/pages/[slug].js:676:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async getStaticProps$1 (/var/task/.next/server/pages/[slug].js:156:31)
at async /var/task/node_modules/@sentry/nextjs/cjs/server/utils/wrapperUtils.js:38:14 {
page: '/vmi-gets-a-commitment-from-2023-3-star-cb-davion-corpening'
}
RequestId: 0581bce3-020b-4225-902f-5ad7b122e9b2 Error: Runtime exited with error: exit status 1
Runtime.ExitError
However, the tweet does exist https://twitter.com/IamTheKeyDC/status/1556693648762437637
About this issue
- Original URL
- State: open
- Created 10 months ago
- Reactions: 5
- Comments: 22 (1 by maintainers)
This is because X is blocking those requests from common hosting providers so you want to get data locally or from the browser in a panel and then save that data in some sort of cache.
The solution is to use Manual Data Fetching locally on build time when you can access X API with
getTweet(tweetId)andgetTweet(tweetId). This can be done on localhost or in browser using user IP address.When you get that data you want to cache it. I recommend Vercel/KV or Redis. I implemented it and I’m very happy how it’s working. There was only one issue when I was using Next.js App Router with static pages - check next point.
When using Next.js App Router with SSG/ISR (
force-static) then the KV get callkv.get(tweetId)won’t work when you build it or deploy it to Vercel. The issue you will see would be:This is happening when you
pnpm buildandpnpm startlocally or when you build and deploy on Vercel.The solution to fix KV call on static pages is to refactor it to use Vercel KV REST API with caching options.
Example static friendly KV get call example:
Yeah I just checked my website and it’s working as well now… I made no changes to the code.
I got the issue resolved!!!.
I have an issue in development.
As you can see, the tweet is working fine is production but in development it says tweet not found or something like giving an network error:
Solution
The solution to this problem is using ‘use client’ in development and remove once you go into the production. As you know that the code is working in production but causing problems in development which causes problems in development.
Result
I am manually fetching the data through a TRPC call and it still doesn’t work
Same here makes the package unusable for me
Yea not entirely sure, but I even tried with the
apiUrlroute that they mention but shouldn’t need to use if I am in Next.js and then locally my tweets won’t load. What’s odd is I use this component in my Sanity studio to preview tweets and it works just fine… Not sure why on my website it doesn’t.