admin管理员组文章数量:1335361
I have a Django application deployed with Krakend gateway. All endpoints are active. But the service is unable to access the request data.
I'm giving the request as below
curl --location '' \
--header 'Content-Type: application/json' \
--data '{
"a":"value",
"b":"value"
}'
This is the response that i get
{
"a": [
"This field is required."
],
"b": [
"This field is required."
]
}
I'm passing all the missing variables correctly. But somehow it is not reaching the service. It works perfectly on localhost. The issue is only with the deployed instance.
Below is the krakend configuration part for this microservice
{
"endpoint": "api/v1",
"method": "POST",
"output_encoding": "no-op",
"backend": [
{
"url_pattern": "api/v1",
"encoding": "no-op",
"sd": "static",
"method": "POST",
"host": ["http://localhost:8000"],
"disable_host_sanitize": false
}
],
"input_headers": ["Authorization","Content-Type"],
"extra_config": {
"qos/ratelimit/router": {
"max_rate": 100,
"client_max_rate": 60,
"every": "1m",
"strategy": "ip"
}
}
}
Thanks.
I have a Django application deployed with Krakend gateway. All endpoints are active. But the service is unable to access the request data.
I'm giving the request as below
curl --location 'https://backend-dev-url/api/v1' \
--header 'Content-Type: application/json' \
--data '{
"a":"value",
"b":"value"
}'
This is the response that i get
{
"a": [
"This field is required."
],
"b": [
"This field is required."
]
}
I'm passing all the missing variables correctly. But somehow it is not reaching the service. It works perfectly on localhost. The issue is only with the deployed instance.
Below is the krakend configuration part for this microservice
{
"endpoint": "api/v1",
"method": "POST",
"output_encoding": "no-op",
"backend": [
{
"url_pattern": "api/v1",
"encoding": "no-op",
"sd": "static",
"method": "POST",
"host": ["http://localhost:8000"],
"disable_host_sanitize": false
}
],
"input_headers": ["Authorization","Content-Type"],
"extra_config": {
"qos/ratelimit/router": {
"max_rate": 100,
"client_max_rate": 60,
"every": "1m",
"strategy": "ip"
}
}
}
Thanks.
Share Improve this question edited Nov 20, 2024 at 10:08 Geo Joseph asked Nov 20, 2024 at 4:49 Geo JosephGeo Joseph 91 silver badge6 bronze badges1 Answer
Reset to default 0The gateway does not manipulate or filter the payload unless you add a component that does it, so if you send --data
it reaches the service as it is. The problem lies somewhere else.
I see some inconsistencies in the configuration you have passed.
- The
curl
calls an endpoint/api
, but your configuration declares/api/v1
. So either you pasted here the wrong configuration or the request won't reach the place you expect - In production, it is weird that the Django app is on the same machine as KrakenD. I see the backend points to
localhost:8000
. If you use different machines or Docker containers, you must update this host to the correct one.
版权声明:本文标题:python - Deployed Krakend Django microservice not receiving any input data given in json body - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742381164a2464120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论