Rank 1: Thread
can someone help me to sort out the authentication problem in appwrite? when ever I try to call the account.createOAuth2Session/(or any other methods) an error that says Uncaught TypeError: Cannot read properties of undefined (reading 'replace') and the full error is
Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
at Client.setEndpoint (appwrite.js?v=026b3d50:707:89)
at appwrite.js:5:6
here is my code appwrite.js
import { Account, Client } from "appwrite";
const client = new Client()
.setEndpoint(import.meta.env.APPWRITE_ENDPOINT)
.setProject(import.meta.env.APPWRITE_PROJECT_ID)
export const account = new Account(client);
export default client;
export { ID } from 'appwrite';
and the app.jsx is
import './App.css';
import { account } from './lib/appwrite';
function App() {
const google = async () => {
account.createOAuth2Session('google', 'http://localhost:5173/auth/google/success', 'http://localhost:5173/auth/google/failure');
}
return (
<>
<div>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={google}>Google</button>
</div>
</>
)
}
export default App