framework icon indicating copy to clipboard operation
framework copied to clipboard

Nuxt3 rc13: useFetch(...) POST ignoring header Content-Type ( Client side app )

Open janschiefer opened this issue 3 years ago • 10 comments

Environment

RootDir: /home/xxx/yyy 01:48:06 Nuxt project info: 01:48:06


  • Operating System: Linux
  • Node Version: v18.12.1
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: debug, runtimeConfig, modules, app
  • Runtime Modules: -
  • Build Modules: -

👉 Report an issue: https://github.com/nuxt/framework/issues/new 01:48:06

👉 Suggest an improvement: https://github.com/nuxt/framework/discussions/new

👉 Read documentation: https://v3.nuxtjs.org

Reproduction


await useFetch(() => "/my/post/url", {
        method: 'POST',
        mode: 'no-cors',
        headers: {
	    	"Content-Type": "application/json"
	  	},
        body: add_to_cart_data,
        initialCache: false,
        
        onResponse({ request, response, options }) {
    	    // Process the response data	    	 
    	},
    	
    } );

Developer tools "network inspection" in Chrome: POST /addToCart HTTP/1.1 Accept-Encoding: gzip, deflate, br Accept-Language: de-DE,de;q=0.9,en-GB;q=0.8,en;q=0.7,en-US;q=0.6 Connection: keep-alive Content-Length: 43 Content-Type: text/plain;charset=UTF-8 DNT: 1 Host: localhost:8080 Origin: https://localhost:3000 Sec-Fetch-Dest: empty Sec-Fetch-Mode: no-cors Sec-Fetch-Site: cross-site User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 accept: application/json sec-ch-ua: "Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Linux"

Developer tools in Firefox: POST /addToCart HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0 Accept: application/json Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate, br Content-Type: text/plain;charset=UTF-8 Content-Length: 43 Origin: null Connection: keep-alive Sec-Fetch-Dest: empty Sec-Fetch-Mode: no-cors Sec-Fetch-Site: same-site

Describe the bug

Content type should be the value set in the function call, here "application/json".

Additional context

REPRODUCTION (added 14.11.2022): https://stackblitz.com/edit/nuxt-starter-d5y9os

Logs

No response

janschiefer avatar Nov 14 '22 00:11 janschiefer