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

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 brendangibson