Skip to content

Fix "unsafe headers" bug in browser

Dwayne Charrington requested to merge feature/user-agent-bugfix into master

As per the issue here when attempting to use Dhive in the browser, you get an unsafe headers error. This error is a blocking error and prevents the client from working.

The fix here was to use the proper whatwg-fetch polyfill for browser environments in the appropriate browser index file. And finally, inside of client.ts only set the user agent for Node and not in browser environments by using a safe check for self which is not added in by any tooling or additional libraries like other properties such as exports or even window.

Furthermore, I tested this quite extensively in one of my own dApps which was broken as a result and it now works as intended.

Merge request reports

Loading