Flask: KeyError when retrieving value from Flask session via AJAX call in Edge

Viewed 30

We have a site that's embedded in an iFrame. We basically have a 3rd party solution where we can add applications/sites into and it's then just displayed in an iFrame. Nothing fancy about it.

This all sits on Windows Servers and IIS

The application in question is a Flask one and has two routes as follows:

@blue.route("/set", methods=["GET"])
def set_the_session():
    session["encounter_id"] = "ABCDEF
    return session["encounter_id"]

@blue.route("/get", methods=["GET"])
def get_the_session():
    return session["encounter_id"]

If I visit the first route and then the second route, it works fine, I get the value ABCDEF

However if I add a 3rd route and add this to the template:

$.get("/get", function(data, status){
    alert("Data: " + data + "\nStatus: " + status);
});

I get the following error:

return session["encounter_id"]
    KeyError: 'encounter_id'

This is in Microsoft Edge. This works in Chrome, Firefox and even IE.

However, if I visit the 3rd route outside of the iFrame then there's no issue, it works fine.

So the issue only appears in Edge when the application is in an iFrame. I've tried withCredentials with the AJAX request but nothing

The web.config file has the following:

<cors enabled="true" failUnlistedOrigins="true">
    <add origin="*" />
</cors>

Any suggestions?

0 Answers
Related