fix: Force JSON content-type for REST API requests

This commit is contained in:
NaiJi 2023-06-05 09:46:42 -03:00
parent 7a80590fc8
commit a690fb5089
5 changed files with 25 additions and 5 deletions

View file

@ -30,7 +30,11 @@ class BackblazeApi extends ApiMap {
@override
BaseOptions get options {
final BaseOptions options = BaseOptions(baseUrl: rootAddress);
final BaseOptions options = BaseOptions(
baseUrl: rootAddress,
contentType: Headers.jsonContentType,
responseType: ResponseType.json,
);
if (isWithToken) {
final BackblazeCredential? backblazeCredential =
getIt<ApiConfigModel>().backblazeCredential;

View file

@ -26,7 +26,11 @@ class CloudflareApi extends DnsProviderApi {
@override
BaseOptions get options {
final BaseOptions options = BaseOptions(baseUrl: rootAddress);
final BaseOptions options = BaseOptions(
baseUrl: rootAddress,
contentType: Headers.jsonContentType,
responseType: ResponseType.json,
);
if (isWithToken) {
final String? token = getIt<ApiConfigModel>().dnsProviderKey;
assert(token != null);

View file

@ -26,7 +26,11 @@ class DesecApi extends DnsProviderApi {
@override
BaseOptions get options {
final BaseOptions options = BaseOptions(baseUrl: rootAddress);
final BaseOptions options = BaseOptions(
baseUrl: rootAddress,
contentType: Headers.jsonContentType,
responseType: ResponseType.json,
);
if (isWithToken) {
final String? token = getIt<ApiConfigModel>().dnsProviderKey;
assert(token != null);

View file

@ -36,7 +36,11 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi {
@override
BaseOptions get options {
final BaseOptions options = BaseOptions(baseUrl: rootAddress);
final BaseOptions options = BaseOptions(
baseUrl: rootAddress,
contentType: Headers.jsonContentType,
responseType: ResponseType.json,
);
if (isWithToken) {
final String? token = getIt<ApiConfigModel>().serverProviderKey;
assert(token != null);

View file

@ -37,7 +37,11 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
@override
BaseOptions get options {
final BaseOptions options = BaseOptions(baseUrl: rootAddress);
final BaseOptions options = BaseOptions(
baseUrl: rootAddress,
contentType: Headers.jsonContentType,
responseType: ResponseType.json,
);
if (isWithToken) {
final String? token = getIt<ApiConfigModel>().serverProviderKey;
assert(token != null);