question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when add options `mode: "no-cors"` it break the request and Apollo Server fail, 500 error

See original GitHub issue

Intended outcome: GraphQL call execute without CORS

Actual outcome: server response 500 error

How to reproduce the issue: use this code in the client, occur all the time.

const apolloClient = new ApolloClient({
	networkInterface: createNetworkInterface(
		{
			uri: "http://domain.com/graphql?",
			opts: {
				mode: "no-cors",
			},
		}),
	dataIdFromObject: (value:any) => value.id,
	initialState: {},
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
helfercommented, Jun 30, 2017

I’m pretty sure this has nothing to do with apollo-client because it just passes the option to the underlying fetch library. I suggest you open the issue there, or on the server library if you think the server is at fault.

14reactions
d9sucommented, Oct 25, 2018

Apparently it’s an issue on the server side, nothing to do with the apollo client. Context: https://github.com/github/fetch/issues/318#issuecomment-249573195

TL;DR is that in no-cors mode, the Content-Type header becomes immutable and can only take one of these values: application/x-www-form-urlencoded, multipart/form-data, or text/plain. Hence if we want to be in no-cors mode, the server needs to be able to handle the content as these content types 🤷‍♂️ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring CORS - Apollo GraphQL Docs
You can enable credentials with CORS by setting the Access-Control-Allow-Credentials HTTP header to true . You must specify an origin to enable credentialed...
Read more >
Migrating to Apollo Server 4 - Apollo GraphQL Docs
In Apollo Server 3, the top-level dataSources constructor option essentially adds a post-processing step to your app's context function, creating DataSource ...
Read more >
Error handling - Apollo GraphQL Docs
Setting HTTP status code and headers · If Apollo Server hasn't correctly started up or is in the process of shutting down, it...
Read more >
Handling operation errors - Apollo GraphQL Docs
These are errors encountered while attempting to communicate with your GraphQL server, usually resulting in a 4xx or 5xx response status code (and...
Read more >
Apollo-server-express sometimes return cors error - Help
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. Why same client...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found