Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple request passing with http package but not with dio #1601

Closed
cedvdb opened this issue Dec 1, 2022 · 2 comments
Closed

Simple request passing with http package but not with dio #1601

cedvdb opened this issue Dec 1, 2022 · 2 comments

Comments

@cedvdb
Copy link

cedvdb commented Dec 1, 2022

dio web has headers in its request which are not allowed for "Simple request", which means some request which shouldn't trigger preflight will trigger it. EG CORS errors.

There is a strict policy on how to be elligible for what's called "simple request":

Simple request
A simple cross-site request is one that meets all the following conditions:

The only allowed methods are:

GET
HEAD
POST
Apart from the headers set automatically by the user agent (e.g. Connection, User-Agent, etc.), the only headers which are allowed to be manually set are:

Accept
Accept-Language
Content-Language
Content-Type
The only allowed values for the Content-Type header are:

application/x-www-form-urlencoded
multipart/form-data
text/plain
A simple request will not cause a pre-flight OPTIONS request


Here is an example URL which does not pass with dio https://homologation-webpayment.payline.com/webpayment/getToken but will pass with the http package, content type should be x-www-form-urlencoded, just make a POST request with whatever data, DIO will trigger a preflight and a CORS issue

@alvarobcprado
Copy link

Same problem

@DonRubiczek
Copy link

I am still having same issue dio: ^5.4.1. Sending normal post with MultipartFile, not changing or setting any headers. Should be counted as Simple Request but somehow sending by dio triggers OPTIONS request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants