From 294b1a5a7c694e781a01ddb686a51dc681d8cf47 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Sun, 22 Aug 2021 22:44:07 +0530 Subject: [PATCH] fix: cors when content-type is set for simple requests --- components/http/Body.vue | 27 ++++++++++++++++++++------- components/http/RawBody.vue | 2 +- helpers/types/HoppRESTRequest.ts | 3 +++ helpers/utils/EffectiveURL.ts | 19 ++++++++++++------- newstore/RESTSession.ts | 12 +++++++----- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/components/http/Body.vue b/components/http/Body.vue index b1195fe3f..3f67cfa7a 100644 --- a/components/http/Body.vue +++ b/components/http/Body.vue @@ -24,11 +24,20 @@ + - + +
+ + {{ $t("empty.body") }} + +
@@ -59,11 +76,7 @@ export default defineComponent({ return { validContentTypes: Object.keys(knownContentTypes), - contentType: useStream( - restContentType$, - "application/json", - setRESTContentType - ), + contentType: useStream(restContentType$, null, setRESTContentType), } }, }) diff --git a/components/http/RawBody.vue b/components/http/RawBody.vue index c35d1657b..2640af832 100644 --- a/components/http/RawBody.vue +++ b/components/http/RawBody.vue @@ -31,7 +31,7 @@ @click.native="clearContent('rawParams', $event)" /> { contentType: newContentType, - body: curr.request.body.body, + body: + newContentType === null + ? undefined + : (curr.request.body as any).body, }, }, } @@ -591,7 +593,7 @@ export function updateFormDataEntry(index: number, entry: FormDataKeyValue) { }) } -export function setRESTContentType(newContentType: ValidContentTypes) { +export function setRESTContentType(newContentType: ValidContentTypes | null) { restSessionStore.dispatch({ dispatcher: "setContentType", payload: {