'Having issues with sending JWT via AXIOS ..normal routes work however AJAX post says no JWT available

So I have this endpoint below(Block 2) called from the directly below(Block 1)...the headers I see in the browser appear to be sending the access_token_cookie in the cookie header....I also have a after_header block(Block 3)

THE AXIOS CALL FROM THE PAGE

var myFunction = function(element){
    console.log(element.innerText);
    axios.defaults.withCredentials = true;
    axios.post('/api/cmsaudit/'+element.innerText).then(function(response){
        //console.log(response.data);
        document.getElementById('resultcol').innerHTML = response.data;
    }).catch(function(error){
    })

THE AJAX ENDPOINT CALL

@cms_blueprint.route('/api/cmsaudit/<cause>',methods=['POST','GET'])
@jwt_required()  <---- if I remove this it works fine.
def applist(cause):
    f = open('cause.txt','w')
    f.write('inhere')
    f.write(str(datetime.now()))
    getapps = OracleConnect()
    opencon = getapps.openconnection()
    if opencon == 0:
        if cause == 'List Applications':
            getapps.mycursor.execute("QUERY")
        result = getapps.mycursor.fetchall()
        getapps.closeconnection
        print(result)
        results = {}
        results["value"]=[]
        for x in result:
            results["value"].append(x[0])
        sys.stdout.flush()
        return render_template('cmsaudit/applist.html',applist=results["value"])
        return jsonify(results),200
    else:
        f.write('else is running')
        return jsonify({'msg':str(opencon)})

AFTER REQUEST BLOCK TO CHECK/REFRESH TOKEN

@app.after_request
def refresh_expiring_jwts(response):
    try:
        now = datetime.now()
        if request.path == '/api/jwt/check':
            return response
        exp_timestamp = get_jwt()["exp"]
        
        target_timestamp = datetime.timestamp(now + timedelta(minutes=28))
        
        if target_timestamp > exp_timestamp:
            access_token = create_access_token(identity=get_jwt_identity())
            set_access_cookies(response, access_token)
        return response
    except (RuntimeError, KeyError):
        # Case where there is not a valid JWT. Just return the original respone
        return response


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source