Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function createUserAgentMiddleware(
options: UserAgentMiddlewareOptions
): Middleware {
const userAgent = createHttpUserAgent({
name: 'commercetools-js-sdk',
...options,
})
return (next: Dispatch): Dispatch => (
request: MiddlewareRequest,
response: MiddlewareResponse
) => {
const requestWithUserAgent = {
...request,
headers: {
...request.headers,
'User-Agent': userAgent,
},
}
next(requestWithUserAgent, response)