question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid request body

See original GitHub issue

Describe the bug

I upgraded svelte-kit to its latest version today. I configured my project to use the new vite.config.js setup, however now “Invalid request body” is the only response I get in the browser for all routes (except proxy rules). It’s occurring while using the default starter/skeleton project as well. Screen Shot 2022-07-05 at 6 23 32 PM Screen Shot 2022-07-05 at 6 23 51 PM

There are no errors reported in the terminal. Configured server proxy rules do resolve.

Reproduction

npm create svelte my-app cd my-app npm install npm run dev – --open

Logs

➜  my-app pnpm dev -d             

> my-app@0.0.1 dev /Users/keithrose/Workspace/svelte-test/my-app
> vite dev "-d"

(node:56433) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
  vite:vite-plugin-svelte svelte inspector path: /Users/keithrose/Workspace/svelte-test/my-app/node_modules/@sveltejs/vite-plugin-svelte/src/ui/inspector/ +0ms
  vite:config native esm config loaded in 144.40ms URL {
  href: 'file:///Users/keithrose/Workspace/svelte-test/my-app/vite.config.js',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: '',
  hostname: '',
  port: '',
  pathname: '/Users/keithrose/Workspace/svelte-test/my-app/vite.config.js',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
} +0ms
  vite:vite-plugin-svelte findSvelteDependencies: searching svelte dependencies in /Users/keithrose/Workspace/svelte-test/my-app +38ms
  vite:vite-plugin-svelte adding bare svelte packages to optimizeDeps.include: svelte/animate, svelte/easing, svelte/internal, svelte/motion, svelte/store, svelte/transition, svelte  +1ms
  vite:vite-plugin-svelte automatically excluding found svelte dependencies:  +0ms
  vite:vite-plugin-svelte reincluding transitive dependencies of excluded svelte dependencies [] +0ms
  vite:vite-plugin-svelte additional vite config {
  resolve: {
    mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
    dedupe: [
      'svelte/animate',
      'svelte/easing',
      'svelte/internal',
      'svelte/motion',
      'svelte/ssr',
      'svelte/store',
      'svelte/transition',
      'svelte',
      'svelte-hmr/runtime/hot-api-esm.js',
      'svelte-hmr/runtime/proxy-adapter-dom.js',
      'svelte-hmr'
    ]
  },
  optimizeDeps: {
    include: [
      'svelte/animate',
      'svelte/easing',
      'svelte/internal',
      'svelte/motion',
      'svelte/store',
      'svelte/transition',
      'svelte'
    ],
    exclude: [ 'svelte-hmr' ]
  },
  ssr: { noExternal: [], external: [] }
} +1ms
  vite:vite-plugin-svelte Setting compilerOptions.hydratable: true for SvelteKit +12ms
  vite:vite-plugin-svelte resolved options {
  hot: { injectCss: false },
  compilerOptions: { css: false, dev: true, hydratable: true },
  extensions: [ '.svelte' ],
  emitCss: true,
  preprocess: [
    {
      defaultLanguages: [Object],
      markup: [AsyncFunction: markup],
      script: [AsyncFunction: script],
      style: [AsyncFunction: style]
    },
    { style: [Function: style] }
  ],
  kit: {
    adapter: { name: '@sveltejs/adapter-auto', adapt: [Function: adapt] }
  },
  configFile: '/Users/keithrose/Workspace/svelte-test/my-app/svelte.config.js',
  root: '/Users/keithrose/Workspace/svelte-test/my-app',
  isBuild: false,
  isServe: true,
  isDebug: true,
  isProduction: false
} +1ms
  vite:vite-plugin-svelte inspector disabled, could not find config +1ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite-plugin-svelte',
  vite:config     'vite-plugin-svelte:inspector',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:optimized-deps',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite-plugin-svelte-kit',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] },
  vite:config     port: 3000,
  vite:config     strictPort: true,
  vite:config     watch: { ignored: [Array] }
  vite:config   },
  vite:config   resolve: {
  vite:config     dedupe: [
  vite:config       'svelte/animate',
  vite:config       'svelte/easing',
  vite:config       'svelte/internal',
  vite:config       'svelte/motion',
  vite:config       'svelte/ssr',
  vite:config       'svelte/store',
  vite:config       'svelte/transition',
  vite:config       'svelte',
  vite:config       'svelte-hmr/runtime/hot-api-esm.js',
  vite:config       'svelte-hmr/runtime/proxy-adapter-dom.js',
  vite:config       'svelte-hmr'
  vite:config     ],
  vite:config     mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
  vite:config     alias: [ [Object], [Object], [Object], [Object], [Object] ]
  vite:config   },
  vite:config   optimizeDeps: {
  vite:config     include: [
  vite:config       'svelte/animate',
  vite:config       'svelte/easing',
  vite:config       'svelte/internal',
  vite:config       'svelte/motion',
  vite:config       'svelte/store',
  vite:config       'svelte/transition',
  vite:config       'svelte'
  vite:config     ],
  vite:config     exclude: [ 'svelte-hmr' ],
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   },
  vite:config   ssr: { noExternal: [], external: [] },
  vite:config   base: '/',
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {
  vite:config       input: '/Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/runtime/client/start.js'
  vite:config     },
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   preview: {
  vite:config     port: 3000,
  vite:config     strictPort: true,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   root: '/Users/keithrose/Workspace/svelte-test/my-app',
  vite:config   configFile: '/Users/keithrose/Workspace/svelte-test/my-app/vite.config.js',
  vite:config   configFileDependencies: [ '/Users/keithrose/Workspace/svelte-test/my-app/vite.config.js' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   publicDir: '/Users/keithrose/Workspace/svelte-test/my-app/public',
  vite:config   cacheDir: '/Users/keithrose/Workspace/svelte-test/my-app/node_modules/.vite',
  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isWorker: false,
  vite:config   isProduction: false,
  vite:config   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) {},
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object], [Object],
  vite:config       [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   }
  vite:config } +54ms
  vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

  vite v2.9.13 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 373ms.

  vite:resolve 1.91ms /.svelte-kit/generated/root.svelte -> /Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/generated/root.svelte +0ms
  vite:load 1.59ms [fs] /.svelte-kit/generated/root.svelte +0ms
  vite:vite-plugin-svelte setting cssHash s-cCKfmRoJfo02 for /.svelte-kit/generated/root.svelte +5s
  vite:vite-plugin-svelte transform returns compiled js for /Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/generated/root.svelte +61ms
  vite:import-analysis 0.63ms [0 imports rewritten] .svelte-kit/generated/root.svelte +0ms
  vite:transform 64.87ms /.svelte-kit/generated/root.svelte +0ms
  vite:resolve 0.34ms /.svelte-kit/runtime/paths.js -> /Users/keithrose/Workspace/svelte-test/my-app/.svelte-kit/runtime/paths.js +116ms
  vite:load 4.08ms [fs] /.svelte-kit/runtime/paths.js +116ms
  vite:import-analysis 0.05ms [no imports] .svelte-kit/runtime/paths.js +53ms
  vite:transform 0.58ms /.svelte-kit/runtime/paths.js +53ms
  vite:time 216.33ms / +0ms
  vite:time 1.15ms /favicon.ico +50ms

System Info

System:
    OS: macOS 12.5
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 122.75 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.7.0 - ~/.nvm/versions/node/v16.7.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.20.3 - ~/.nvm/versions/node/v16.7.0/bin/npm
  Browsers:
    Brave Browser: 103.1.40.107
    Chrome: 103.0.5060.53
    Firefox Nightly: 84.0a1
    Safari: 15.6
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.53 
    @sveltejs/kit: next => 1.0.0-next.359 
    svelte: ^3.44.0 => 3.48.0 
    vite: ^2.9.13 => 2.9.13

Severity

blocking all usage of SvelteKit

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
georgdonnercommented, Nov 12, 2022

I just created a new project based on the Svelte demo app and testing out the Sverdle, I am getting the same response as you guys above “Invalid request body” (see screenshot). I have also tested this with a skeleton project and a custom POST endpoint and am running into the same issue there as well. Is anyone else able to reproduce this?

Node versions tested: v16.15.1, v16.18.0 and v18.12.0

@sveltejs/adapter-auto”: “1.0.0-next.84”, “@sveltejs/kit”: “1.0.0-next.525”,

Screenshot 2022-10-27 at 20 16 04
0reactions
Rich-Harriscommented, Jul 6, 2022

@rajasegar it’s not like it was intentional

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid request body /400 bad request - Help - Postman
"status": "ERROR", "description": "Invalid request body. " ... This means you sent data to your API in the incorrect format. If you want ......
Read more >
jquery - Input JSON is invalid. Request body must be valid ...
Input JSON is invalid. Request body must be valid JSON if content type is application/json. I checked above JSON object with jsonlint.com ...
Read more >
Troubleshooting Error Messages
Invalid Request URL/Parameter. This type of error message occurs when the request URL or a request body parameter contains invalid or improperly formatted...
Read more >
Invalid Request errors - Docs - Plaid
One or more fields in the request body were invalid, malformed, or used a wrong type. · Personally identifiable information (PII), such as...
Read more >
Invalid Request Body - API - Forum | Webflow
Hi, We are importing external data to Webflow with the API. We are also importing HTML markup to Webflow Rich Text field in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found