oembed-extractor icon indicating copy to clipboard operation
oembed-extractor copied to clipboard

Refused to set unsafe header "user-agent"

Open markhats opened this issue 2 years ago • 4 comments

Hi

I'm getting the following console error when using this lib in Chrome.

image

Any ideas how to prevent this?

Thanks.

markhats avatar Feb 23 '22 09:02 markhats

@markhats thank you, it seems relate to Chrome secure policy.

ndaidong avatar Feb 24 '22 12:02 ndaidong

JUST REMOVE THE USER AGENT HEADER..

HardikPanchal427345 avatar Apr 07 '22 09:04 HardikPanchal427345

@ndaidong I have the same problem.

I've tried doing the following before calling extract(url):

setRequestOptions({
  headers: {
    accept: 'application/json; charset=utf-8',
  },
});

and

setRequestOptions({
  headers: {
    'user-agent': '',
    accept: 'application/json; charset=utf-8',
  },
});

and

setRequestOptions({
  headers: {
    'user-agent': undefined,
    accept: 'application/json; charset=utf-8',
  },
});

and

setRequestOptions({
  headers: {
    'user-agent': null,
    accept: 'application/json; charset=utf-8',
  },
});

None of these helped, I'm still getting Refused to set unsafe header "user-agent" on the console.

I've also tried passing these parameters to extract() directly, but that also didn't help.

Can you help me out on how to avoid this error?

dJani97 avatar Oct 25 '22 16:10 dJani97

@dJani97 thank you for raising issue. If you are using TypeScript , there is exactly some mistakes in type declaration. I will release v3.1.3 to fix. Please test it again after that.

ndaidong avatar Oct 26 '22 05:10 ndaidong