Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS Issue #184

Open
Lishenga opened this issue Nov 7, 2020 · 13 comments
Open

CORS Issue #184

Lishenga opened this issue Nov 7, 2020 · 13 comments

Comments

@Lishenga
Copy link

Lishenga commented Nov 7, 2020

Hello am getting this error when trying to get an introspection of your graphql api using graphql voyager

Access to fetch at 'https://graphql.org/swapi-graphql' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Could you kindly assist me or tell me why am getting this error?

@acao
Copy link
Member

acao commented Nov 20, 2020

@acao
Copy link
Member

acao commented Nov 20, 2020

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

@nishanthsinghgurung2
Copy link

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

@chackop
Copy link

chackop commented Feb 13, 2021

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.

@ttbarnes
Copy link

ttbarnes commented Feb 16, 2021

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

@kiliw
Copy link

kiliw commented Apr 5, 2021

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

@liztownd
Copy link

liztownd commented Jun 9, 2021

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

@SupeDeDupe
Copy link

SupeDeDupe commented Aug 16, 2021

Same issue

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

@o-az
Copy link

o-az commented Sep 4, 2021

Same issue here

@JoshuaFurman
Copy link

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

@o-az
Copy link

o-az commented Sep 11, 2021

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

@Deevoid
Copy link

Deevoid commented Jan 23, 2022

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.

@acao
Copy link
Member

acao commented Feb 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests