2 consecutive preflight requests with the first one getting failed immediately and later passes

Hi Team, I am new to Apollo and I have recently migrated to Apollo Server v4. After migration, I see in the network tab of Chrome’s dev tool that there are two preflight requests, the first one fails immediately, and the later one passes, and in the subsequent fetch request, the correct response is returned.
I have set the csrfPrevention to false when creating the server. Not sure how to get around this issue, any help will be highly appreciated.
Thanks!

Hey @goelsarthak93, can you share a reproduction or at least some more details? Are you seeing Sandbox send 2 preflight requests, or are the requests coming from your graphql client (if so which one)?

Can you send more details about the requests you’re seeing?

We have an ApolloClient configured in our front-end react application, in the network tab, I see there are two preflight requests, the first one fails immediately though the second preflight request succeeds. The request method is missing in the first preflight request.

@goelsarthak93 Is it an OPTIONS request by any chance?

In a basic example I’m unable to reproduce. I only see one preflight, with no missing method. Can you share a reproduction?

Yes, it’s an OPTIONS request, ideally, the apollo/client should be sending only 1 request but somehow in the browser’s network request I see 2 preflight requests 1 w/o OPTIONS getting failed and the other with OPTIONS as the request method getting passed. I am unable to figure out why there are 2 preflight requests for a single request.


As you see, there are 2 preflight requests for a same request to server, and the first one gets failed immediately before even being sent to server

I’d be happy to help, but I unfortunately can’t debug the issue if I can’t reproduce it locally. Can you share a repo or codesandbox with instructions on how to run and trigger the error?

Hi, I’m pretty sure your issue is related to these changes in Chrome: Private Network Access update: Introducing a deprecation trial - Chrome Developers