2

I'm developing an SO chrome extension in React with TypeScript.

I've been reading the guide on how to use the API with OAuth and it looks fantastic for what I'm trying to do.

The problem is that the API seems to depend on a localhost or server instance it can communicate with (channelUrl domain error occurs), and since I'm running a Chrome extension build I don't have a server it can do that with.

Is there a way of not using a server with a blank page prepared for privileged API calls?

1 Answer 1

1

After looking at the API code in JavaScript, it seems that this error is thrown if the channelUrl doesn't match the URL you're currently at.

To get round this, just set the channelUrl to a dynamic value that updates for every window

{
  "channelUrl": window.location.protocol + "//" + window.location.host
}

If you run this in the console of your browser you'll see that it logs the base URL of the website you're currently on, and the error will no longer be thrown.

Update, this just delays the problem unfortunately. When it comes to authenticating the login it fails because of an unexpected domain on proxy url.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .