Code Monkey home page Code Monkey logo

Comments (13)

chackop avatar chackop commented on May 4, 2024 4

Hello, I am also getting the similar CORS issue when trying to use swapi-graphql with the v3 Apollo client in react:
https://www.apollographql.com/docs/react/get-started/#create-a-client

My Apollo client configuration is as follows:

const client = new ApolloClient({
  uri: "https://graphql.org/swapi-graphql",
  cache: new InMemoryCache(),
  headers: {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "DELETE, POST, GET, OPTIONS",
    "Access-Control-Allow-Headers":
      "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With",
  },
  credentials: "omit",
});

As seen I had tried setting the headers and credentials property but still getting the same error.
Please let me know if there is anything else I can try.

from swapi-graphql.

SupeDeDupe avatar SupeDeDupe commented on May 4, 2024 4

Same issue

edit: here's an alternative endpoint that seems to work https://swapi-graphql.netlify.app/.netlify/functions/index

from swapi-graphql.

Deevoid avatar Deevoid commented on May 4, 2024 4

Hello, I am also getting the similar CORS issue when trying to use swapi-graphql with the v3 Apollo client in react: https://www.apollographql.com/docs/react/get-started/#create-a-client

My Apollo client configuration is as follows:

const client = new ApolloClient({
  uri: "https://graphql.org/swapi-graphql",
  cache: new InMemoryCache(),
  headers: {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "DELETE, POST, GET, OPTIONS",
    "Access-Control-Allow-Headers":
      "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With",
  },
  credentials: "omit",
});

As seen I had tried setting the headers and credentials property but still getting the same error. Please let me know if there is anything else I can try.

Replace your URI with this and it will work:
https://swapi-graphql.netlify.app/.netlify/functions/index

NOTE: remove the headers object as they are not needed anymore.

from swapi-graphql.

o-az avatar o-az commented on May 4, 2024 3

I'm having the same problem. Has anyone been able to come across a solution?

@JoshuaFurman use this alternative endpoint:

https://swapi-graphql.netlify.app/.netlify/functions/index

from swapi-graphql.

ttbarnes avatar ttbarnes commented on May 4, 2024 1

i'm getting the same issue. Any help please? Sounds like the API needs to allow * access, otherwise introduce API keys?

from swapi-graphql.

acao avatar acao commented on May 4, 2024

try using this fetch option:

credentials: 'omit'

here's en example:
https://github.com/graphql/graphiql/blob/6ca519a9f0b0b9c55e77f8b4a73320036cba5652/packages/graphiql/resources/renderExample.js#L119

from swapi-graphql.

acao avatar acao commented on May 4, 2024

@Lishenga you may need to open an issue in graphql voyager

from swapi-graphql.

nishanthsinghgurung2 avatar nishanthsinghgurung2 commented on May 4, 2024

I am getting this issue too. Any idea how to fix this issue ?

from swapi-graphql.

kiliw avatar kiliw commented on May 4, 2024

Any updates on this? I'm also getting the same error.

from swapi-graphql.

liztownd avatar liztownd commented on May 4, 2024

Chiming in to ask if there is any update on this issue? Still getting the same error when trying to access the API. Thanks!!

from swapi-graphql.

o-az avatar o-az commented on May 4, 2024

Same issue here

from swapi-graphql.

JoshuaFurman avatar JoshuaFurman commented on May 4, 2024

I'm having the same problem. Has anyone been able to come across a solution?

from swapi-graphql.

acao avatar acao commented on May 4, 2024

I think we need to change the graphql netlify _redirects to proxy the old path?

from swapi-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.