cfug / cfug/dio

Use modern Fetch API with Dio on Web

Open
#1,740 21 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

e: performance e: PR welcomed p: web_adapter platform: web s: best practise s: feature valuable
Dominant language
Dart
Stars
12.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Request Statement

I am trying to figure out Dio and CORS on web. Google is used here as an example, but it could be anything.

Currently if you were to make a request with Dio to "https://www.google.com/" on web. Your request would fail with a transport error, as the browser blocks the request because Google does not reply with the header that allows the browser to do this.

This is done to prevent websites from sending requests to Google with your current cookies, which could be dangerous.

But what happens if you just want to request the page without cookies? As if you were never logged in at all. It seems that XMLHttpRequest only wants to send cookies, or not send anything at all.

Is this doable with the modern Fetch API? https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
It looks like there are different modes for cors. Possibly one with this effect?

If so than should there be an option to use this modern Fetch API with Dio? Especially when modern Fetch API allows for streaming, which is not possible with XMLHttpRequest.

Solution Brainstorm

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the issue’s Fetch API and XMLHttpRequest references, focusing on CORS modes, cookie handling, and streaming on the web. The issue names no repository files, entry points, or tests, and does not define a concrete API or implementation scope; completion would require an agreed design and validation criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
networking, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.