0

In my browser I see the url and it starts with "HTTPS ://ide50etc". I get the EM however that says "loading... HTTP ://ide50etc". Why does it do that? It doesn't happen all the time. When my session is still clean this EM is created but once filled with stuff it disappears. Or is it? I force the template to be rendered again and then I get another EM: Cross-Origin-aanvraag geblokkeerd: de Same Origin Policy staat het lezen van de externe bron op https://ide50-oyz1.cs50.io:8080/processWord niet toe. (Reden: CORS-header ‘Access-Control-Allow-Origin’ ontbreekt). The header is missing. So I've installed flask-cors. And I added :

from flask_cors import CORS app = Flask(__name__) CORS(app)

Right? But alas, the same message persists. I am now banging my head against the wall. Even if it worked, I'd love to understand this and I really don't. I use an ajax post request to post a json object and attach a promise to that. When done a second request is fired that sends images and sounds. I don't really know what code is relevant except all of it, of course but that's quite a lot. Please let me know what more info you need.

$('#jsonSubmit').on('submit', function(event) { $.ajax({ url : "/processWord", type: 'POST', contentType:'application/json', data: sendFormData }).done(function(response) { $('#formulier').trigger('submit') }).fail(function(xhr) { console.log('error', xhr); } }); event.preventDefault(); }); });

1 Answer 1

0

Ok, I did it again, asked a question I could have found the answer for without asking but somehow that helps. flask_cors is the answer. There was some remnant in the code somewhere that must have recreated the EM (I guess.) I took it out( I rendered the template again with a click event) and now everything works fine. I cannot believe it, probably I'll be editing this again. But maybe there is mercy and I am finally in the light.

Here are all the examples and explanations: https://media.readthedocs.org/pdf/flask-cors/latest/flask-cors.pdf

```

from flask import Flask
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route("/")
  defhelloWorld():
     return "Hello, cross-origin-world!"

```

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .