I thought this might be a server issue. But these two functions that worked perfectly before , all of a sudden , don’t work and I get this error :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://q1oclm9r8ql7.grandmoralis.com:2053/server/classes/Cuser. (Reason: CORS request did not succeed).
It looks like it keeps trying to complete the request over and over as well. This is new because the code worked great before. Im starting to get scared because these weird errors keep cropping up. Please help me.
partial code:
import { useMoralis } from "react-moralis";
const { Moralis } = useMoralis();
async function checkThisUser( em1: string, em2: string) {
const Cuser = Moralis.Object.extend("Cuser");
const query = new Moralis.Query(Cuser);
query.equalTo("email1", em1);
const results = await query.find();
let goodUser = "yes"; // good = if not in the database
for(let i = 0; i < results.length; i++){
const object = results[i];
if( object.get("email2") === em2 ){
alert("duplicate sign in - not allowed") ;
goodUser = "no";
}
}
return goodUser;
}
async function saveNewUser ( email1: string, email2:string, code1: string, code2: string ) {
const Cuser = Moralis.Object.extend("Cuser");
const cuser = new Cuser();
cuser.set('muser', Moralis.User.current())
cuser.set('email1', email1)
cuser.set('email2', email2)
cuser.set('code1', code1)
cuser.set('code2', code2)
let fEmail = email1 + email2;
cuser.set('userFullEmail', fEmail)
let response = cuser.save();
console.log(response);
return;
}
//(other function )
let sv = await saveNewUser(email1, email2, code1, code2);
let sd = await sendEmail(email1, email2, code1, code2);