Reputation: 31
Getting error in API calling
ERROR => Access to XMLHttpRequest at 'localhost:3003/graphql' from origin 'http://localhost:8101' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
apollo: Apollo,
httpLink: HttpLink
) {
apollo.create({
link: httpLink.create({ uri: 'localhost:3003/graphql}),
cache: new InMemoryCache()
});
CORS-enabled for all origins (Node Api)
Upvotes: 0
Views: 91
Reputation: 3966
As error refers only supported for protocol schemes: http....
which certainly means you've just forgotten to put the https
or http
on the request in your code
So please note localhost:3003/graphql
must change to either http://localhost:3003/graphql
or https://localhost:3003/graphql
apollo: Apollo,
httpLink: HttpLink
) {
apollo.create({
link: httpLink.create({ uri: 'http://localhost:3003/graphql'}),
cache: new InMemoryCache()
});
Upvotes: 2