@sil why do you need to pass Cookies that you don't have access too?
@intrbiz 'cos in another tab, I am logged into couchdb so I can see its admin interface. What I want to do is be able to generate a fetch() request which doesn't use the cookies even though I have them, and it turns out that's impossible, which is quite annoying. It is good that fetch() has the ability to use pre-existing cookies, but I would also like to be able to turn that good behaviour off and provide my own explicit credentials and I can't.
@sil so why can't you make a fetch request with credentials false and adding and authorization header with your authorisation. Presumably your app is authenticating your user and has the resulting authorisation token.
@intrbiz because if you set credentials:false and also set an Authorization header, then your authorization header is not passed by the fetch() call even though you set it, because it's a credential.
@sil I don't think that is the case. That is controlled by CORS headers.
I definitely have apps setting a bearer token with fetch.
@intrbiz ah, fair, in detail it applies to basic auth headers, not all Authorization headers. (https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials confirms.) So eventually if I shift to bearer tokens or JWTs or something then this problem would be alleviated, but I'm not in a position to do that yet :)
@sil ahh, interesting nuance
@intrbiz because if you've got cookies for that site and you turn on credentials:include on fetch, the cookies get sent. If you turn off credentials, then it won't send an Authorization header either, even if you set one. So if there are cookies present and an Auth header, you can either send both of them or neither of them with the fetch(), but you can't send one and not the other.