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?
The problem was due to
mode: 'no-cors',
. With this set, the headers are ignored.