I have a django app and at the template part i have javascript function 
calling the rest api:


<!-- Custom Theme JavaScript -->
<script src="/static/js/select-autofiller.js 
<http://komandor.app.gittigidiyor.net:8000/static/js/select-autofiller.js>">
</script>

At the js file i am filling a select box according to the returned json 
response

$('#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 
getting 


XMLHttpRequest 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?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f920ccf-9948-4e57-8976-a79a7385be0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to