when add options `mode: "no-cors"` it break the request and Apollo Server fail, 500 error
See original GitHub issueIntended 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:
- Created 6 years ago
- Reactions:5
- Comments:7 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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, theContent-Type
header becomes immutable and can only take one of these values:application/x-www-form-urlencoded
,multipart/form-data
, ortext/plain
. Hence if we want to be inno-cors
mode, the server needs to be able to handle the content as these content types 🤷♂️ .