Skip to content

Respect the 'origin' setting in a non-browser environment #80

@matmilbury

Description

@matmilbury

It bothers me I can't set origin when connecting with frame.

More precisely, I can set it but it's ignored by eth-provider:

// Below not working becasue XHR lib blocks it claiming "restricted header"
// if (this.options.origin) xhr.setRequestHeader('Origin', this.options.origin)

Now, I know in a browser environment sets this for a correct value and a user can't do that programmaticaly.

But in node environments (like a cli tool) we can and should set this up to have clarity which program requests a connection.

Therefore, we should:

try {
  if (this.options.origin) xhr.setRequestHeader('Origin', this.options.origin)
} catch {
  // browser environment will set this to the correct value
}

@floating I can create a PR if you want?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions