swapi-graphql
swapi-graphql copied to clipboard
CORS Issue
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?
try using this fetch option:
credentials: 'omit'
here's en example: https://github.com/graphql/graphiql/blob/6ca519a9f0b0b9c55e77f8b4a73320036cba5652/packages/graphiql/resources/renderExample.js#L119
@Lishenga you may need to open an issue in graphql voyager
I am getting this issue too. Any idea how to fix this issue ?
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.
i'm getting the same issue. Any help please? Sounds like the API needs to allow * access, otherwise introduce API keys?
Any updates on this? I'm also getting the same error.
Chiming in to ask if there is any update on this issue? Still getting the same error when trying to access the API. Thanks!!
Same issue
edit: here's an alternative endpoint that seems to work https://swapi-graphql.netlify.app/.netlify/functions/index
Same issue here
I'm having the same problem. Has anyone been able to come across a solution?
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
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.
I think we need to change the graphql netlify _redirects to proxy the old path?