[8.18] [Kibana Dev Server] Fix DELETE requests without a body in Safari (#220899) (#220967)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Kibana Dev Server] Fix `DELETE` requests without a body in Safari
(#220899)](https://github.com/elastic/kibana/pull/220899)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Robert
Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-05-20T07:35:30Z","message":"[Kibana
Dev Server] Fix `DELETE` requests without a body in Safari
(#220899)\n\nRecently, we discovered that a `DELETE` request to one of
our ML\nendpoints does not work correctly in Safari.\nAfter further
investigation, it turns out that `DELETE` requests without\na body fail
in Safari.\nThe issue occurs only within the Kibana Dev server, so there
is no\nimpact on end users.\nThis is most likely due to a header set in
the\n`packages/kbn-cli-dev-mode/src/base_path_proxy/http1.ts` file. The
issue\nmentioned in the comment has already been resolved, and
everything\nappears to work correctly without this outdated
workaround.\n\nTo reproduce the error:\n1. Start Kibana locally and open
it with Safari.\n2. Find an endpoint that uses the `DELETE` method and
does not have a\nbody specified.\n3. ^ For example, go to Observability
-> Cases and create a new case.\n4. Go back to the cases list and try to
delete the
case","sha":"fa0500c346389758fb09935be246752dcdbbb6f3","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:http","Team:Operations","release_note:skip","backport:version","v9.1.0","v8.19.0","v8.17.7","v8.18.2","v9.0.2"],"title":"[Kibana
Dev Server] Fix `DELETE` requests without a body in
Safari","number":220899,"url":"https://github.com/elastic/kibana/pull/220899","mergeCommit":{"message":"[Kibana
Dev Server] Fix `DELETE` requests without a body in Safari
(#220899)\n\nRecently, we discovered that a `DELETE` request to one of
our ML\nendpoints does not work correctly in Safari.\nAfter further
investigation, it turns out that `DELETE` requests without\na body fail
in Safari.\nThe issue occurs only within the Kibana Dev server, so there
is no\nimpact on end users.\nThis is most likely due to a header set in
the\n`packages/kbn-cli-dev-mode/src/base_path_proxy/http1.ts` file. The
issue\nmentioned in the comment has already been resolved, and
everything\nappears to work correctly without this outdated
workaround.\n\nTo reproduce the error:\n1. Start Kibana locally and open
it with Safari.\n2. Find an endpoint that uses the `DELETE` method and
does not have a\nbody specified.\n3. ^ For example, go to Observability
-> Cases and create a new case.\n4. Go back to the cases list and try to
delete the
case","sha":"fa0500c346389758fb09935be246752dcdbbb6f3"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.18","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/220899","number":220899,"mergeCommit":{"message":"[Kibana
Dev Server] Fix `DELETE` requests without a body in Safari
(#220899)\n\nRecently, we discovered that a `DELETE` request to one of
our ML\nendpoints does not work correctly in Safari.\nAfter further
investigation, it turns out that `DELETE` requests without\na body fail
in Safari.\nThe issue occurs only within the Kibana Dev server, so there
is no\nimpact on end users.\nThis is most likely due to a header set in
the\n`packages/kbn-cli-dev-mode/src/base_path_proxy/http1.ts` file. The
issue\nmentioned in the comment has already been resolved, and
everything\nappears to work correctly without this outdated
workaround.\n\nTo reproduce the error:\n1. Start Kibana locally and open
it with Safari.\n2. Find an endpoint that uses the `DELETE` method and
does not have a\nbody specified.\n3. ^ For example, go to Observability
-> Cases and create a new case.\n4. Go back to the cases list and try to
delete the
case","sha":"fa0500c346389758fb09935be246752dcdbbb6f3"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/220964","number":220964,"state":"OPEN"},{"branch":"8.17","label":"v8.17.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2025-05-20 17:55:28 +02:00 committed by GitHub
parent bbb6719d37
commit 3a59f5d50f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -126,12 +126,6 @@ export class Http1BasePathProxyServer implements BasePathProxyServer {
xforward: true,
mapUri: async (request: Request) => {
return {
// Passing in this header to merge it is a workaround until this is fixed:
// https://github.com/hapijs/h2o2/issues/124
headers:
request.headers['content-length'] != null
? { 'content-length': request.headers['content-length'] }
: undefined,
uri: Url.format({
hostname: request.server.info.host,
port: this.devConfig.basePathProxyTargetPort,