Skip to content

Electron main process incorrectly detected as browser #161

@BeaudanBrown

Description

@BeaudanBrown

I believe the current check to determine if we are in node or browser:

if (typeof module !== "undefined" && module.require && !(typeof process !== "undefined" && process.versions["electron"])) {
    // We are on node.js
....

is flagging both the electron main and renderer processes as browser, causing request calls made from the main process (node) to fail with XMLHttpRequest is not defined

After modifying the check as advised by this comment to the following:

  if (typeof module !== "undefined" && module.require && !(typeof navigator !== "undefined" && /electron/i.test(navigator.userAgent))) {

request calls made from either process work as expected

I don't have a minimum reproducible project so I decided to create an issue rather than a PR in case this is just user error on my end somehow

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething that should function correctly isn't.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions