From 76bf364440959b00926719db1c8a0e4a0e418879 Mon Sep 17 00:00:00 2001 From: Nicolas Gorga <62995075+NicolasGorga@users.noreply.github.com> Date: Thu, 9 Oct 2025 13:58:17 -0300 Subject: [PATCH] fix(js-sdk): pass headers to auth.refresh() (#13690) Fixes #13689 --- .changeset/perfect-parrots-act.md | 5 +++++ packages/core/js-sdk/src/auth/index.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/perfect-parrots-act.md diff --git a/.changeset/perfect-parrots-act.md b/.changeset/perfect-parrots-act.md new file mode 100644 index 0000000000..788e287b49 --- /dev/null +++ b/.changeset/perfect-parrots-act.md @@ -0,0 +1,5 @@ +--- +"@medusajs/js-sdk": patch +--- + +fix(js-sdk): pass headers to auth.refresh() diff --git a/packages/core/js-sdk/src/auth/index.ts b/packages/core/js-sdk/src/auth/index.ts index 70a7a179ad..c117c3440a 100644 --- a/packages/core/js-sdk/src/auth/index.ts +++ b/packages/core/js-sdk/src/auth/index.ts @@ -1,6 +1,6 @@ import { HttpTypes } from "@medusajs/types" import { Client } from "../client" -import { Config } from "../types" +import { ClientHeaders, Config } from "../types" export class Auth { private client: Client @@ -214,6 +214,7 @@ export class Auth { * For an example of implementing third-party authentication, refer to the * [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide. * + * @param headers - Headers to pass in the request * * @returns The refreshed JWT authentication token. * @@ -225,11 +226,12 @@ export class Auth { * // all subsequent requests will use the token in the header * const { customer } = await sdk.store.customer.retrieve() */ - refresh = async () => { + refresh = async (headers?: ClientHeaders) => { const { token } = await this.client.fetch<{ token: string }>( "/auth/token/refresh", { method: "POST", + headers, } )