Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API routes not recieving body when build with netlify-adapter and deployed to netlify #862

Closed
chiptopher opened this issue Apr 3, 2021 · 1 comment

Comments

@chiptopher
Copy link

Describe the bug
I've got a SvelteKit application set up on netlify using the netlify-adapter. Locally everything works fine. I can make a POST request no problem. However, when I push it up to netlify I get the following error:

ERROR  TypeError: Cannot destructure property 'name' of 'req.body' as it is undefined.

specifically on this line of code:

    const { name } = req.body;

A console.log of the entire request reveals that the request netlify receives has no body at all.

Looking at the source for the netlify-adapter, I think this line of code might be the culprit.

Expected behavior
I would expect the body of my API request to be appropriately forwarded to the render netlify function.

Information about your SvelteKit Installation:

Diagnostics
  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 305.93 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.3 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.6 - /usr/local/bin/npm
  Browsers:
    Chrome: 89.0.4389.114
    Firefox: 87.0
    Safari: 14.0.1
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.66 
    svelte: ^3.29.0 => 3.37.0 
    vite: ^2.1.0 => 2.1.5
  • Your adapter: netlify

Severity
I don't think it's a huge deal. I could write out my API routes as raw netlify functions, or, if I wanted to stay in SvelteKit, I could probably turn my body into request query parameters since it looks like they're being forwarded to the renderer, so I have a path forward if I want to keep using netlify. I could probably also try a different host.

@chiptopher
Copy link
Author

This appears to have been resolved as a part of #1109. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants