-
Notifications
You must be signed in to change notification settings - Fork 93
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
Tweet Not Found #137
Comments
I am currently experiencing the same issue. Could it be related to the recent update to version 3.1.1? |
Yea not entirely sure, but I even tried with the |
Same here makes the package unusable for me |
Yea hopefully someone from Vercel can take a look or give some guidance. I guess looking at the documentation for Next, I should be manually fetching this data since I generate static params for my articles? |
I am manually fetching the data through a TRPC call and it still doesn't work |
I was looking at how @steven-tey was doing it in Dub https://github.com/steven-tey/dub/tree/main and the tweets are clearly loading for him and he is using |
@lfades any guidance here for us? It's currently blocking a couple of us from actually being able to use this library. |
I'm experiencing the same issue at the moment |
Yea I even tried how a couple of Vercel engineers use react-tweet and either end up my pages with tweets just completely 404ing or in the same position that I am in right now. |
From some googling it seems to be Twitter blocking AWS, what I don't understand is how others have it working |
Not an ideal solution but I got it working using a proxy and recreating the function:
|
@lleewwiiss I wonder if that is why @steven-tey and other Vercel employees cache the tweet results in upstash/redis? |
Maybe but in the example app if you enter a random tweet ID that I assume isn't cached it still seems to work, It might also be a Cors thing but I'll just use a proxy until this is resolved or we have some guidance. |
Yeah I'm not sure anymore either as I've tried the api route they have as an example in this repo and I still get that it's not found. |
Surprisingly today, it worked on my website!! Nothing changed in my code... |
Yeah I just checked my website and it’s working as well now… I made no changes to the code. |
Me as well with no proxy |
This is happening when you 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: // fetching tweets and caching in KV
const TweetIds = ["1705688070941520030","1705162823003734354"]
const tweets: Tweet[] = [];
if (TweetIds) {
for (const tweetId of TweetIds) {
let kvTweet: Tweet | undefined | null = null;
// check kv cache first
try {
const res = await fetch(
`${process.env.KV_REST_API_URL}/get/tweet:${tweetId}`,
{
headers: {
Authorization: `Bearer ${process.env.KV_REST_API_TOKEN}`,
},
cache: "force-cache",
next: {
tags: [`tweets`],
},
} as any
);
const json = await res.json();
kvTweet = JSON.parse(json.result) as Tweet;
} catch (err) {
console.log(err);
console.log("Error fetching tweet from KV");
}
if (kvTweet) {
tweets.push(kvTweet);
} else {
// fetch tweet
try {
const tweet = await getTweet(tweetId);
if (tweet) {
tweets.push(tweet);
// cache tweet in KV
await kv.set(`tweet:${tweetId}`, tweet);
}
} catch (e) {
console.warn(`Error fetching tweet ${tweetId} from X`);
console.warn(e);
}
}
}
} |
I had almost the same experience. https://twitter.com/t6adev/status/1746699829336780921
I'm not sure about it. But I can say something We need to take a workaround against Twitter's behavior. |
I am back to getting this error in production again... It says the tweet was not found... However, in my CMS (Sanity) it shows it just fine They are both on the same domain and my sanity studio is built directly into my Next.js application. What is weird is there was a query param of like |
I solved the issue by enabling the cache as mentioned in the documentation. const getTweet = unstable_cache(
async (id: string) => {
return _getTweet(id)
},
["tweet"],
{ revalidate: 3600 * 24 },
)
const TweetPage = async ({ id }: { id: string }) => {
try {
const tweet = await getTweet(id)
return tweet ? <EmbeddedTweet tweet={tweet} /> : <TweetNotFound />
} catch (error) {
console.error(error)
return <TweetNotFound error={error} />
}
}
const X = ({ id }: { id: string }) => {
return (
<Suspense fallback={<TweetSkeleton />}>
<TweetPage id={id} />
</Suspense>
)
} <X id="0123456789" /> |
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
However, the tweet does exist https://twitter.com/IamTheKeyDC/status/1556693648762437637
The text was updated successfully, but these errors were encountered: