HTTP Compression
If you've enabled HTTP Compression in your Medusa configurations, and you want to disable it for some requests, you can pass the x-no-compression
header in your requests:
x-no-compression: true
If you're using the Medusa JS Client, you can pass custom headers in the last parameter of a method. For example:
medusa.products.list({}, {
"x-no-compression": true
})
.then(({ products, limit, offset, count }) => {
console.log(products.length)
})
You can also pass the header when you first initialize the Medusa client:
const medusa = new Medusa({
maxRetries: 3,
baseUrl: "https://api.example.com",
customHeaders: {
"x-no-compression": true
}
})
For Medusa React, it's not possible to pass custom headers for a query or mutation, but you can pass the header to the MedusaProvider
and it will be added to all subsequent requests:
import { MedusaProvider } from "medusa-react"
// define query client...
const App = () => {
return (
<MedusaProvider
queryClientProviderProps={{ client: queryClient }}
baseUrl="http://localhost:9000"
// ...
customHeaders={{
"x-no-compression": true
}}
>
<MyStorefront />
</MedusaProvider>
)
}
Modified at a year ago