Initially, the user id and password are submitted from the UI (angular) to Flask:
public send_login(user){
console.log(user)
return
this.http.post(this.apiURL+'/login',JSON.stringify(user),this.httpOptions)
.pipe(retry(1),catchError(this.handleError))
}
Subsequently, it is received from the backend.
While all operations are functioning correctly, a cross-origin error is appearing in the console.
The HTTP options on the UI side are as follows:
constructor(private http: HttpClient) { }
// Http Options
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'http://localhost:9000',
'Access-Control-Allow-Methods': "GET,POST,OPTIONS,DELETE,PUT",
'X-Requested-With': 'XMLHttpRequest',
'MyClientCert': '', // This is empty
'MyToken': ''
})
}
The CORS declaration in the backend is stated below:
cors = CORS(app, resources={r"/login": {"origins": "*"}})
@app.route('/login', methods=['GET','POST'])
def loginForm():
json_data = ast.literal_eval(request.data.decode('utf-8'))
print('\n\n\n',json_data,'\n\n\n')
I am unable to pinpoint where the issue is arising.
Note: The cross-origin error occurs during the login process, but not in subsequent steps.