I'm making a next.js website and using the library Twitter-lite, to access the Twitter API. For some reason the code run normaly in my local server, but when I send it to vercel, to publish it, it doesn't work, It returs
502: BAD_GATEWAY
Code: NO_RESPONSE_FROM_FUNCTION
ID: gru1::dzfhn-1612303490166-f7e971564512
the code is:
import Twitter from "twitter-lite";
export default async function getUserTweets(request, response) {
var amount = 10
const client = new Twitter({
subdomain: "api",
consumer_key: process.env.TWITTER_API_KEY,
consumer_secret: process.env.TWITTER_SECRET_API_KEY,
access_token_key: process.env.TWITTER_TOKEN,
access_token_secret: process.env.TWITTER_TOKEN_SECRET,
bearer_token:process.env.TWITTER_BEARER_TOKEN
});
let timeline = await client.get("statuses/user_timeline", {
screen_name: "nerat0",
exclude_replies: true,
include_rts: false,
tweet_mode: "extended",
count: amount + 2
});
response.json(timeline)
}
OBS: in vercel Function Log it says: errors: [ { code: 32, message: 'Could not authenticate you.' } ]
. But how could I run normaly in local with the same authentication...
Can anyone help me with a link or a explanation? Thanks :)