Skip to content

[web_adapter] CORS warning claims withCredentials forces a preflight, so every credentialed simple request is flagged #2634

Closed as not planned

Description

@uveshm003

Package: web_adapter
Version: 2.2.2 (main @ f1bef46)
Operating-System: Web
Adapter: Default Dio
Dart Version: 3.12.2

collectCorsPreflightReasons treats withCredentials: true as a preflight trigger. That isn't how CORS works: preflight depends only on the method, the request headers and upload listeners, not on credentials mode (Fetch spec "main fetch" step; MDN: "a simple GET request is not preflighted" even with credentials). As a result, BrowserHttpClientAdapter(withCredentials: true) logs the "will trigger a preflight (OPTIONS) request" warning on every plain GET, and any network error on such a request gets a misleading "not a CORS simple request" hint.

Steps to Reproduce

import 'package:dio/dio.dart';
import 'package:dio_web_adapter/src/cors.dart';

void main() {
  final options = RequestOptions(path: 'https://api.example.com/me'); // simple GET
  print(collectCorsPreflightReasons(options, withCredentials: false));
  print(collectCorsPreflightReasons(options, withCredentials: true));
}

Expected Result

[]
[]

Actual Result

[]
[withCredentials is enabled, which requires a CORS preflight request]

Cause: plugins/web_adapter/lib/src/cors.dart:77-81 (used at adapter_impl.dart:85-89 for both the warning and the onError message).

Suggested fix: drop the withCredentials reason from collectCorsPreflightReasons. If a credentials hint is still useful, add it only to the onError message, worded as "the server must send Access-Control-Allow-Credentials: true and a non-wildcard origin".

Activity

  1. github-actions commented on Nov 3, 2026

    @github-actions
    Contributor

    @uveshm003 Infra and blank issues are only available for moderators. You're apparently using the wrong issue template.

    Infra 和空白 issue 仅供管理人员使用,请选择其他 issue 模板创建 issue。

  2. locked as off topic and limited conversation to collaborators on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions