Frontend API Code (fetch async JS):
export async function auth(username, password){
const constUSER = username
const constPASS = password
const api_url_auth = "http://127.0.0.1:5000/login/" + constUSER + "/" + constPASS
const response = await fetch(api_url_auth,{
method: "POST",
headers:{
'Access-Control-Allow-Origin':'*'
}
});
const data = await response.json();
return data
}
Backend API Code (flask Python):
@beapi.route("/login/<username>/<password>", methods = ['POST'])
@cross_origin(supports_credentials=True)
def login (username, password):
global userdetails
global account_id
#Find The Data inside the Collection Check's if the username is available
userdetails = database.get_Account_LogIn_Details(username)
databasepwr = userdetails[2] #password Database
account_id = userdetails[0] #Account Id
pwr = password
dict_true = {"response": "True"}
dict_false = {"response": "False"}
dict_NF = {"response" : "NF"}
#Returns True or False Verification Process
if userdetails != "e0101db":
if pwr == databasepwr:
database.update_Time_In(account_id= account_id, date=date, time=time )
return jsonify(dict_true)
else:
return jsonify(dict_false)
else:
return jsonify(dict_NF)
What I did so far:
added CORS(myAPI)
on the backend and added mode:"no-cors"
on the frontend. None work so far and what I added in my question so far is the closest (I think) I've gotten to solving this problem