Skip to content

Commit 01a0366

Browse files
author
Elliot Yibaebi
committed
fix sso metadata upload issue
1 parent d7456ad commit 01a0366

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

app/components/sso-settings/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export default class SsoSettingsComponent extends Component<SsoSettingsSignature
149149

150150
await this.ajax.post(url, {
151151
data: idpFormData,
152-
contentType: 'multipart/form-data',
153152
});
154153

155154
this.idpMetadataXml = null;

app/services/ajax.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ export default class IreneAjaxService extends Service {
265265
// Only include headers if _shouldSendHeaders returns true
266266
const headers = this._shouldSendHeaders(finalUrl, options.host)
267267
? {
268-
'Content-Type': options.contentType || 'application/json',
268+
// For data transfer objects we allow the browser set the content type of the request
269+
...([FormData, Blob].some(
270+
(dataType) => options.data instanceof dataType
271+
)
272+
? {}
273+
: { 'Content-Type': options.contentType || 'application/json' }),
269274
...this.defaultHeaders,
270275
...options.headers,
271276
}
@@ -327,11 +332,13 @@ export default class IreneAjaxService extends Service {
327332
* @param {Response} response - The fetch response to parse.
328333
* @returns {Promise<any | string>} - The parsed JSON or raw text.
329334
*/
330-
private async parseResponseText<T>(response: Response): Promise<T | string> {
335+
private async parseResponseText<T extends object>(
336+
response: Response
337+
): Promise<T | string> {
331338
const text = await response.text();
332339

333340
try {
334-
return text ? JSON.parse(text) : {};
341+
return text ? JSON.parse(text) : ({} as T);
335342
} catch {
336343
return text;
337344
}

0 commit comments

Comments
 (0)