Repository navigation
fix: make Mode::default() cors, like fetch, and deprecate Mode::Navigate - #121
Open
QuantumExplorer wants to merge 1 commit into
Open
QuantumExplorer wants to merge 1 commit into
QuantumExplorer wants to merge 1 commit into
Conversation
Mode::default() was NoCors. fetch's default mode is cors, and a grpc-web call cannot work in no-cors mode across origins: its headers are not CORS-safelisted and the response is opaque, so every call made with FetchOptions::new().mode(Mode::default()) failed with "Failed to fetch". FetchOptions leaves the mode unset by default, so only code that asks for Mode::default() is affected. Mode::Navigate can never work: fetch rejects every request whose mode is navigate. It is deprecated rather than removed, so code that names it keeps compiling. Fixes devashishdxt#107 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #107.
Problem
Mode::default()isNoCors. fetch's default mode iscors, and a grpc-web call does not work inno-corsmode across origins, because its headers are not CORS-safelisted and the response is opaque.FetchOptions::new().mode(Mode::default())makes every call fail withJS API error: TypeError: Failed to fetch.Mode::Navigatecan never work either, since fetch rejects every request whose mode isnavigate. #107 has a reproduction for both.Fix
Corsis the#[default]variant, matching fetch. TheNoCorsdocs say why a grpc-web call cannot work in that mode.Navigateis deprecated rather than removed, so code that names it keeps compiling.FetchOptions::default()leaves the mode unset, so only code that asks forMode::default()sees a change.Before and after
FetchOptions::new().mode(Mode::default())no-cors, every call fails withFailed to fetchcors, calls workFetchOptions::new()cors)FetchOptions::new().mode(Mode::Navigate)Navigateis deprecatedTests
Unit test
default_is_cors_like_fetchinsrc/options/mode.rs.cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo clippy --target wasm32-unknown-unknown -- -D warningsandcargo testare clean, and the browser suite intest-suite/simplepasses in headless Chrome 153.This is one of 14 PRs from the review asked for in #97. They are independent, and all 14 also merge together cleanly; with all of them merged, both browser suites (
test-suite/simpleandtest-suite/gzip) pass.🤖 Generated with Claude Code