Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Alarco committed May 13, 2024
2 parents ca1193c + f1f935c commit e08be22
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/client/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { Wallet, PaymentResult, Store } from '../index';
export function setupL402Interceptor(instance: AxiosInstance, wallet: Wallet, store: Store): void {
// Request interceptor to set an authorization header if a token is available
instance.interceptors.request.use((config: InternalAxiosRequestConfig<any>) => {
// Combine baseURL and URL into a fully qualified URL if baseURL is specified
const url = config.baseURL ? new URL(config.url ?? '', config.baseURL).toString() : config.url;
const url = axios.getUri(config); // Get the fully qualified URL
const method = config.method?.toUpperCase() || 'GET'; // Use 'GET' as the default method

// Retrieve the token using the fully qualified URL and HTTP method
Expand Down Expand Up @@ -40,7 +39,7 @@ export function setupL402Interceptor(instance: AxiosInstance, wallet: Wallet, st
if (paymentResult.success) {
// Create a new L402 token and store it
const l402Token = `${challenge.header_key} ${challenge.macaroon}:${paymentResult.preimage}`;
const url = config.baseURL ? new URL(config.url ?? '', config.baseURL).toString() : config.url;
const url = axios.getUri(config); // Get the fully qualified URL
const method = config.method?.toUpperCase() || 'GET'; // Use 'GET' as the default method

// Store the new token with the fully qualified URL and method
Expand Down

0 comments on commit e08be22

Please sign in to comment.