apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

how to enable no-cors mode in apollo-client ^3.0.0

Open agarwalchaitanya opened this issue 3 years ago • 3 comments

looking for something similar from the APIs before v3.0.0 (given below)

export const client = new ApolloClient({
    uri: ""
    cache: new InMemoryCache(),
    fetchOptions: {
        mode: 'no-cors'
    }
});

agarwalchaitanya avatar Jun 08 '21 09:06 agarwalchaitanya

Have you found a solution to this? We are also very much in trouble here.

tgoorden avatar Sep 07 '21 08:09 tgoorden

any updates in this??

sgClaudia98 avatar Dec 09 '21 04:12 sgClaudia98

I found the following on stackoverflow:

import { ApolloClient, HttpLink } from '@apollo/client';

const client = new ApolloClient({
  link: new HttpLink({
      uri: 'your client uri goes here',
      fetchOptions: {
         mode: 'cors', // no-cors, *cors, same-origin
      }
  }),
});

https://stackoverflow.com/a/72316966/8184729

RemyMachado avatar Aug 18 '22 12:08 RemyMachado

@RemyMachado is correct - see https://www.apollographql.com/docs/react/api/link/apollo-link-http/#fetchoptions for more info. Thanks all!

bignimbus avatar Nov 21 '22 20:11 bignimbus