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 when requesting data #51

Open
iamacatperson opened this issue Mar 4, 2019 · 1 comment
Open

CORS issue when requesting data #51

iamacatperson opened this issue Mar 4, 2019 · 1 comment

Comments

@iamacatperson
Copy link

When I try to use the code below to fetch data from Reddit...

import { Reddit } from 'graphqlhub-schemas';
import { GraphQLSchema, graphql } from 'graphql';

let schema = new GraphQLSchema({
  query: Reddit.QueryObjectType
});

let query = '{ subreddit(name: "netflix"){newListings(limit: 10) { title score url } } }';
graphql(schema, query).then((result) => {
  console.log(result);
});

I get a CORS error:
Access to fetch at 'https://reddit.com/r/netflix/about.json' from origin 'http://localhost:3000' has been blocked by CORS policy: 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.

By right https://reddit.com will redirect to the one with www but because of the missing Access-Control-Allow-Origin response header, it doesn't.

Any work around for this?

@onyxnl
Copy link

onyxnl commented Mar 13, 2019

@iamacatperson I also encountered same issue. Did you find solution ?

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

2 participants