fix(js-sdk): pass headers to auth.refresh() (#13690)

Fixes #13689
This commit is contained in:
Nicolas Gorga
2025-10-09 13:58:17 -03:00
committed by GitHub
parent c6896ffa6a
commit 76bf364440
2 changed files with 9 additions and 2 deletions

View File

@@ -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,
}
)