0

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)

1 Answer 1

2

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()
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.