Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Preflight response is not successful" in Apollo Server running on GitHub Codespaces

I followed the Apollo Getting Started example in a Github Codespace.

Upon starting the server, I see the error:

{
  "error": "Preflight response is not successful"
}

Sample repo to reproduce is here: https://github.com/anishkny/codespaces-test

I tried various options for cors but it did not work:

...
new ApolloServer({ typeDefs, resolvers
  cors: {
    "origin": "*",
    "methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
    "preflightContinue": false,
    "optionsSuccessStatus": 204
  }
});
...
like image 316
anishkny Avatar asked Oct 25 '25 06:10

anishkny


1 Answers

I had this same issue. It turns out that Playground is not forwarding your Github credentials. Notice that if you visit the preview URL in an incognito window, you are redirected to the Github login screen. The solution is to change Playground settings so that your credentials are sent in GraphQL requests.

  1. Click the top right corner, click the gear icon (settings)
  2. Change the following
-  "request.credentials": "omit",
+  "request.credentials": "same-origin",
like image 51
charltoons Avatar answered Oct 28 '25 06:10

charltoons



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!