Svelte URQL only sends text/plain as a Content-Type

249 Views Asked by At

I am trying to make my graphQL requests have a Content-Type of 'application/json` using Svelte and URQL. However, every request has a Content-Type of 'text/plain;charset=UTF-8' which my server will not accept.

My code is -

    initClient({
        url: (import.meta.env.VITE_GRAPHQL_URL as string) ?? 'http://localhost:9002/graphql',
        fetchOptions: {
            mode: 'no-cors',
            headers: {
                'Content-Type': 'application/json'
            }
        }
    });

How do I setup URQL on Svelte to send the Content-Type that I want?

1

There are 1 best solutions below

0
On

The problem was due to mode: 'no-cors',. With this set, the headers are ignored.