npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Ability to add custom headers for registry calls?

Hi all. I’m working on a project which requires the inclusion of an API key in headers of the npm publish command, specifically x-api-key.

Is there a way to provide custom headers to the npm publish (or adduser) commands?


There is no way. I would recommend that you use the existing authentication mechanisms.

If you have this in your .npmrc:


Then when talking to we’ll send the following header:

Authorization: Bearer VALUE