Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Remove user agent - Refused to set unsafe header "user-agent" #75

Open
jjaybrown opened this issue Feb 6, 2020 · 3 comments
Open

Remove user agent - Refused to set unsafe header "user-agent" #75

jjaybrown opened this issue Feb 6, 2020 · 3 comments

Comments

@jjaybrown
Copy link

Modern browsers will now reject custom headers being set for user-agent, can the user agent setting on browser/UMD be removed to prevent this error?

@leebenson
Copy link
Member

Setting the user agent should actually not be happening in the browser module.

Are you using @timberio/browser, or the node package?

@jjaybrown
Copy link
Author

Timber node, but it is a React SPA application and uses the winston log transport.

import { Timber } from '@timberio/node'
import { TimberTransport } from '@timberio/winston'

@leebenson
Copy link
Member

Gotcha.

@timberio/node is designed specifically for server-side/Node environments. It uses the Node.js API (such as the built-in streams package), so even if we were to change the User-Agent setting to satisfy the browser, there's no guarantee that other current or future changes would work in the browser.

I'd recommend having separate entry points for the server/browser - you can use the @timberio/js package to instantiate a Browser/Node variant as described here.

That should solve the User-Agent issue for you, but also guarantee that you're using the right version to match the environment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants