Opened 3 years ago

Closed 3 years ago

#32883 closed Bug (invalid)

CORS issue with flutter web and django!

Reported by: Akshat Tamrakar Owned by: nobody
Component: HTTP handling Version: 3.1
Severity: Normal Keywords: CORS, flutter, django_rest_framework, flutter_web, response, request, rest api, json
Cc: akshatt004.at@…, Akshat Tamrakar Triage Stage: Unreviewed
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Sending request to django-rest-framework api from flutter web always results in CORS error sppecifically this Access to XMLHttpRequest at 'http://127.0.0.1:8000/' from origin 'http://localhost:62570' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.

In flutter: Tried putting ever possible header in request headers, not working!
In django: Tried making ALLOWED_HOSTS = * & adding corsheaders at top of middleware list and doing CORS_ALLOW_ALL_ORIGINS = True. Still got the same CORS error. Changing port no of gjango or even flutter doesn't make any change.

This same API is working successfully with react and angular (giving correct response).
There is no issue in flutter framework as it is working fine and getting correct response with other similar API developed using NestJS and dotNet.

I have also opened the issue in stackoverflow

Checklist

Raised initially as discussion #...
This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
I have reduced the issue to the simplest possible case.

Change History (2)

comment:1 by Akshat Tamrakar, 3 years ago

Cc: Akshat Tamrakar added
Needs documentation: set

comment:2 by Tim Graham, 3 years ago

Resolution: invalid
Status: newclosed

This looks like a usage question. See TicketClosingReasons/UseSupportChannels for other ways to get help. If you can explain why Django is at fault, feel free to reopen with an explanation.

Note: See TracTickets for help on using tickets.
Back to Top