发现postman post请求时会有500错误。
➜ ~ curl -H 'Content-Type: application/json' 'http://localhost:8341/webapi/users' -d '{
"userId":22,
"realName":"realName",
"userName":"xxx"
}'
{"data":1,"success":true}% ➜ ~ curl -H 'Content-Type: application/json' 'http://localhost:8341/webapi/users' -vvv -d '{
"userId":22,
"realName":"realName",
"userName":"xxx"
}'
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8341 (#0)
> POST /webapi/users HTTP/1.1
> Host: localhost:8341
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 62
>
* upload completely sent off: 62 out of 62 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=mv
< Content-Length: 25
< Connection: keep-alive
<
* Connection #0 to host localhost left intact
{"data":1,"success":true}% ➜ ~ brew cask install wireshark
用wireshark定位到问题是由于Origin,选择loopback, 用http过滤