<!-- Custom Theme JavaScript --> | |
<script src="/static/js/select-autofiller.js"></script> |
$('#field1').change(function(){
var var1=$("#filed2").val();
var var2=$("#field1 option:selected").text();
url="http://www.foo.com:8080/" + var1 + "/" + var2 + "/";
$.get(url, function( data ) {
alert( "Load was performed." + data);
});
});
The Django web app is running on www.foo.com:8000
At the rest api side, falcon is running and i installed falcon-cors
import falcon
from wsgiref import simple_server
from falcon_cors import CORS
check_python()
cors = CORS(allow_origins_list=settings.ALLOWED_ORIGINS)
api = falcon.API(
media_type='application/json',
middleware=[
# json.RequireJSON(),
# json.JSONTranslator(),
https.RequireHTTPS(),
headers.BaseHeaders(),
handle_404.WrongURL(),
cors.middleware
],
)***route definitions****httpd = simple_server.make_server('0.0.0.0', 8080, api)
httpd.serve_forever()ALLOWED_ORIGINS is a list: ['www.foo.com:8000', 'www.foo.com:8080']Still when i select the box and triggered the js at the Django web app, i am gettingXMLHttpRequest cannot load http://www.foo.com:8080/var1/var2. Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.foo.com:8000' is therefore not allowed access. The response had HTTP status code 400.
I couldn't find ow to fix it.
Any idea?