Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
309 stars 31 forks source link

Access to XMLHttpRequest at 'https://api.twitter.com/1.1/guest/activate.json' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. #361

Closed nrmnqdds closed 10 months ago

nrmnqdds commented 10 months ago

Getting these error when tries to implement the api in Vite React app: image

The code:

import { Auth } from "rettiwt-auth";
import { Rettiwt } from "rettiwt-api";
import { useEffect } from "react";

const DataGenerator = () => {
  useEffect(() => {
    new Auth()
      .getUserCredential({
        email: import.meta.env.VITE_EMAIl,
        userName: import.meta.env.VITE_USERNAME,
        password: import.meta.env.VITE_PASSWORD,
      })
      .then((credential) => {
        console.log(credential);
      });
  }, []);
};

export default DataGenerator;
Rishikant181 commented 10 months ago

That's not the preferred method to for authenticating Rettiwt-API. For the preferred method, have a look at this

Are you perhaps trying to make this request from your web-server?