Did you manage to sort this out? Got the same issue...

On Wednesday, 2 November 2016 15:29:25 UTC+2, Oguz Yarimtepe wrote:
>
> 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 [email protected].
To post to this group, send email to [email protected].
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/0d88923e-60c0-4624-a6d0-21d08a40fed3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to