apollographql / apollo-link-persisted-queries

Persisted Query support with Apollo Link
MIT License
306 stars 33 forks source link

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

Open frederikhors opened 6 years ago

frederikhors commented 6 years ago

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

maxpain commented 5 years ago

+1

pasiba commented 5 years ago

Same question

michael-kleemann commented 4 years ago

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.