当与无服务器结合使用时,NestJs Body()不会填充请求信息

问题描述 投票:0回答:1

运行SLS脱机或SLS部署时,嵌套中的正文装饰器未填充正在传递的对象。

我已经组装了一个小型仓库来为任何感兴趣的人调查这个问题。

https://gitlab.com/claridgicus/nest-serverless-body-issue

SLS离线输出

[Nest] 91880   - 2019-04-24 20:58   [ExceptionHandler] Map#toJSON isn't generic +5ms
TypeError: Map#toJSON isn't generic
    at String.toJSON (c:\Users\Claridgicus\AppData\Roaming\npm\node_modules\serverless\node_modules\core-js\modules\_collection-to-json.js:6:38)
    at Function.<anonymous> (c:\Users\Claridgicus\AppData\Roaming\npm\node_modules\serverless\node_modules\core-js\modules\_ctx.js:18:15)
    at JSON.stringify (<anonymous>)
    at Function.stringify [as default] (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\fast-safe-stringify\index.js:11:18)
    at ModuleTokenFactory.getDynamicMetadataToken (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\@nestjs\core\injector\module-token-factory.js:20:69)
    at ModuleTokenFactory.create (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\@nestjs\core\injector\module-token-factory.js:12:27)
    at ModuleCompiler.compile (c:\Users\Claridgicus\code\serverless-nestjs-master\node_modules\@nestjs\core\injector\compiler.js:19:47)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
 1: std::vector<v8::CpuProfileDeoptFrame,std::allocator<v8::CpuProfileDeoptFrame> >::vector<v8::CpuProfileDeoptFrame,std::allocator<v8::CpuProfileDeoptFrame> >
 2: v8::internal::wasm::SignatureMap::Find
 3: v8::internal::Builtins::CallableFor
 4: v8::internal::Builtins::CallableFor
 5: v8::internal::Builtins::CallableFor
 6: 0000006B886843C1
serverless nestjs
1个回答
0
投票

所以

经过多次探索 - 我在传入的请求上仔细检查了我的标题

在来自美联储的传入POST请求 - 双重检查你正在设置标题 - 并保存自己几个小时不像我:)

    headers: {
        "Content-Type": "application/json"
    },
© www.soinside.com 2019 - 2024. All rights reserved.