fix(ui): 修复空包体请求携带错误的 Content-Type 头导致的接口报错 #1027
Open
+4
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
while user try to delete log file , the ui 调用 createHeaders(),导致 DELETE 等无包体请求也被强制加上了 Content-Type: application/json。 Fastify 服务端在收到此头时会尝试解析 Body,面对空 Body 直接抛出 FST_ERR_CTP_EMPTY_JSON_BODY 错误。
修改后:仅在 options.body 存在时才添加 JSON Content-Type 头。
