GithubHelp home page GithubHelp logo

Comments (6)

vlad-ignatov avatar vlad-ignatov commented on September 28, 2024 1

Yes, that will need fixing. Please use lowercased header names until a fix is released.

Fetch just does the best it can by "merging" these into single value, which is slightly better than ignoring one of them. There is no reliable way to solve this though, so this library should make sure it does not happen and merge headers itself before fetch is called.

from client-js.

brianpos avatar brianpos commented on September 28, 2024

This is the code that does it...

client-js/src/lib.ts

Lines 101 to 105 in 6daa7a5

...options,
headers: {
accept: "application/json",
...options.headers
}

from client-js.

brianpos avatar brianpos commented on September 28, 2024

Solved my own problem changing my code to use the same casing, then it overwrites the default provided value rather than merging (not sure which later does that)
image

from client-js.

brianpos avatar brianpos commented on September 28, 2024

@jmandel found this and confirmed that this is indeed the behavior of fetch, it scans case insensitive in order, hence finding the base provided one first, then the ones provided in the options.
https://fetch.spec.whatwg.org/#terminology-headers
My workaround just clobbers it, and I'm kinda ok with that, but could do the other way around so it was then processed to the end rather than start.

from client-js.

brianpos avatar brianpos commented on September 28, 2024

Maybe a test like this before setting the accept header.
!Object.keys(options).map(k=>k.toLowerCase()).includes("accept")

from client-js.

vlad-ignatov avatar vlad-ignatov commented on September 28, 2024

Should be fixed and released in v2.5.0

from client-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.