react-tweet icon indicating copy to clipboard operation
react-tweet copied to clipboard

CORS error when calling getTweet

Open Amargol opened this issue 2 years ago • 5 comments

Hey, this is a great package. Thanks so much for the effort you all put into this.

I'm trying to use the included getTweet function to get metadata for a tweet given it's tweet id. But I get the following CORS error:

image

However, when I use the <Tweet /> component directly and pass in the ID, it gets the metadata for the tweet just fine.

Why does the CORS error occur when I call getTweet myself, but when the component calls it for me, everything works fine?

Amargol avatar Dec 21 '23 07:12 Amargol

Here's the code I'm using

image

Amargol avatar Dec 24 '23 02:12 Amargol

I was able to resolve this by moving my getTweet wrapper function to a separate file and setting it as server action.

Yugi-2 avatar Jan 23 '24 14:01 Yugi-2

getTweet works only in server side environment, try using server actions.

iRajatDas avatar Feb 29 '24 16:02 iRajatDas

Hi @iRajatDas , @Yugi-2 @Amargol , can you please elaborate, I'm trying to use gettweet() but its throwing cors, how to correctly set it in server action?? I have moved the the gettweet() wrapper function in separate folder and set it as "use server" , still throwing error Screenshot from 2024-09-01 16-30-28

wasifkareem avatar Sep 01 '24 11:09 wasifkareem