jaydenseric/apollo-upload-client

Auth header from link is ignore

zdnk opened this issue · 2 comments

zdnk commented

hello, I cant get the upload working, i always get unauthoized because upload client seems to be inforing authorization header from links I created.

    const auth = setContext((_, { headers }) => {
      if (this.tokenProvider) {
        console.log('installing token')
        this.tokenProvider.get().then((token) => {
          return {
            headers: {
              ...headers,
              Authorization: `Bearer ${token}`
            }
          };
        });
      }

      return Promise.resolve({});
    });

    this._apollo = new ApolloClient({
      cache: new InMemoryCache(),
      link: auth.concat(createUploadLink({ uri: url })),
    });

If you swap createUploadLink with createHttpLink from Apollo Client, does it work any differently?

Closing, due to a lack of response. If more people have a similar issue and answer the above question we can look into it again and reopen if necessary.