Commit c98c7551 authored by tom's avatar tom

remove Authorization header for API calls

parent 12d7b900
......@@ -170,7 +170,6 @@ export interface ApiResource {
endpoint?: string;
basePath?: string;
pathParams?: Array<string>;
needAuth?: boolean; // for external APIs which require authentication
headers?: RequestInit['headers'];
}
......@@ -214,7 +213,6 @@ export const RESOURCES = {
pathParams: [ 'chainId' as const, 'type' as const ],
endpoint: getFeaturePayload(config.features.verifiedTokens)?.api.endpoint,
basePath: getFeaturePayload(config.features.verifiedTokens)?.api.basePath,
needAuth: true,
},
verified_addresses: {
......@@ -222,7 +220,6 @@ export const RESOURCES = {
pathParams: [ 'chainId' as const ],
endpoint: getFeaturePayload(config.features.verifiedTokens)?.api.endpoint,
basePath: getFeaturePayload(config.features.verifiedTokens)?.api.basePath,
needAuth: true,
},
token_info_applications_config: {
......@@ -230,7 +227,6 @@ export const RESOURCES = {
pathParams: [ 'chainId' as const ],
endpoint: getFeaturePayload(config.features.addressVerification)?.api.endpoint,
basePath: getFeaturePayload(config.features.addressVerification)?.api.basePath,
needAuth: true,
},
token_info_applications: {
......@@ -238,7 +234,6 @@ export const RESOURCES = {
pathParams: [ 'chainId' as const, 'id' as const ],
endpoint: getFeaturePayload(config.features.addressVerification)?.api.endpoint,
basePath: getFeaturePayload(config.features.addressVerification)?.api.basePath,
needAuth: true,
},
// AUTH
......
......@@ -8,7 +8,6 @@ import config from 'configs/app';
import isBodyAllowed from 'lib/api/isBodyAllowed';
import isNeedProxy from 'lib/api/isNeedProxy';
import { getResourceKey } from 'lib/api/useApiQuery';
import * as cookies from 'lib/cookies';
import type { Params as FetchParams } from 'lib/hooks/useFetch';
import useFetch from 'lib/hooks/useFetch';
......@@ -32,14 +31,11 @@ export default function useApiFetch() {
resourceName: R,
{ pathParams, queryParams, fetchParams, logError }: Params<R> = {},
) => {
const apiToken = cookies.get(cookies.NAMES.API_TOKEN);
const resource: ApiResource = RESOURCES[resourceName];
const url = buildUrl(resourceName, pathParams, queryParams);
const withBody = isBodyAllowed(fetchParams?.method);
const headers = pickBy({
'x-endpoint': resource.endpoint && isNeedProxy() ? resource.endpoint : undefined,
Authorization: resource.endpoint && resource.needAuth ? apiToken : undefined,
'x-csrf-token': withBody && csrfToken ? csrfToken : undefined,
...resource.headers,
...fetchParams?.headers,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment