Skip to content

fix: devKeys support in flutter by conditionally including credentials #1084

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

Merged
merged 1 commit into from
Jun 1, 2025

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented May 31, 2025

What does this PR do?

Fixes devKeys support in flutter.

When devKeys is set, we treat the authentication method as "keys" based, and thus we should not include "credentials: include". This change was also implemented in web and react native, was left in flutter.

the following error is thrown otherwise:
image

Test Plan

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

yes.

@ChiragAgg5k ChiragAgg5k requested a review from Copilot May 31, 2025 13:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the devKeys support in the Flutter client by conditionally setting the HTTP client's credentials based on the presence of a development key.

  • Removed the unconditional assignment of withCredentials in the cookie fallback block.
  • Introduced combined headers logic to conditionally enable withCredentials depending on the presence of the dev key.
Comments suppressed due to low confidence (1)

templates/flutter/lib/src/client_browser.dart.twig:195

  • If _httpClient is used concurrently for multiple requests, toggling _httpClient.withCredentials per request might introduce race conditions. Ensure that this design is safe under concurrent usage or consider isolating the HTTP client state per request.
final combinedHeaders = {..._headers!, ...headers};

Copy link
Contributor

@stnguyen90 stnguyen90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. To make it better, can you add more context about why this is needed in the PR description?

@ChiragAgg5k
Copy link
Member Author

@stnguyen90 done

@stnguyen90 stnguyen90 merged commit 6d9318a into master Jun 1, 2025
37 checks passed
@stnguyen90 stnguyen90 deleted the fix-devkeys-flutter branch June 1, 2025 04:20
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

Successfully merging this pull request may close these issues.

2 participants