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 error on https://graphql.org/swapi-graphql/ #229

Open
eddeee888 opened this issue Dec 16, 2024 · 3 comments · May be fixed by #230
Open

CORS error on https://graphql.org/swapi-graphql/ #229

eddeee888 opened this issue Dec 16, 2024 · 3 comments · May be fixed by #230
Assignees

Comments

@eddeee888
Copy link

eddeee888 commented Dec 16, 2024

Hi,

I'm getting the following in the browser console whilst accessing https://graphql.org/swapi-graphql/:

Access to fetch at 'https://swapi-graphql.netlify.app/.netlify/functions/index' from origin 'https://graphql.org' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

And here's the screenshot of GraphiQL:
Screenshot 2024-12-16 at 8 10 20 PM

I wonder if the change that happened yesterday may have cause the issue?
Maybe I'm doing something wrong?

@sarahbarberuk
Copy link

I am also experiencing this issue when using the SWAPI GraphQL API with Apollo Studio's GraphQL Explorer that use your API. See screenshot - all queries lead to "Fail to fetch error". The issue seemed to begin around a week ago, at a similar time to the other CORS issues.

apollostudioSWAPIerror

The Apollo Studio support team suggested the issue was at the API's end, which seems to be the case given the CORS issues happening in the last week.

Any chance you could add some extra headers like these below? This GraphQL explorer is great as a companion to tutorial articles explaining how to do stuff in GraphQL.

Access-Control-Allow-Origin: http://studio.apollographql.com
Access-Control-Allow-Methods: GET, POST, OPTIONS

@supaspoida
Copy link

I was able to get this working locally by updating the headers config in this repo and modifying the graphql-http lib via pnpm's patch package support: https://gist.github.com/supaspoida/9362c6130e977a7b633a186d7f8ba2a1

@JoviDeCroock
Copy link
Member

JoviDeCroock commented Dec 23, 2024

This looks to indeed be in GraphQL-HTTP not handling OPTIONS, however we should solve it on our end to avoid graphql-http having an opinion on this

@JoviDeCroock JoviDeCroock linked a pull request Dec 23, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

6 participants