apollo-link-persisted-queries icon indicating copy to clipboard operation
apollo-link-persisted-queries copied to clipboard

CORS GETs issue a PREFLIGHT OPTIONS call. Can we swtich the content-type or not?

Open frederikhors opened this issue 7 years ago • 3 comments

I'm using this amazing package for persisted queries and { useGETForHashedQueries: true }.

Everything works good but I think something is happening if I use ApolloServer with CORS (which I hate and in the future I think I will avoid them with something like a proxy or what will be).

Now the problem is I see some GETs with PREFLIGHT OPTIONS calls.

I think this is happening because of content-type: application/json in Request Headers.

Can we switch this Content-Type to ex. text/plain.

I'm newbie, I don't know if there is a security concern changing the Content-Type.

image

frederikhors avatar Sep 12 '18 20:09 frederikhors

+1

maxpain avatar Feb 09 '19 10:02 maxpain

Same question

pasiba avatar Feb 09 '19 10:02 pasiba

We are also experiencing this issue. As we do have a quite huge amount of different users, our backend(running on cross origin) has to handle mainly cors requests(yes, we are setting cors caching headers).

I tried setting content-type to "text/plain" in createHttpLink-options. This caused no more preflight requests. At the same time it prevents persisting new queries via post-request. In this case we need to have different content-types for get and post requests each.

michael-kleemann avatar May 12 '20 09:05 michael-kleemann