Doing external API calls inside of addons

38 views
Skip to first unread message

John

unread,
May 29, 2024, 6:51:36 AMMay 29
to zotero-dev
Hello!

I was taking a look at the source code of the `zotero-memento` extension. It seems that it has to circumvent CORS restrictions, since it does all requests against a public proxy called cors-anywhere.heroku.app: https://github.com/leonkt/zotero-memento/blob/c40457480d48c839ba24bb4703a34f443f302e04/chrome/content/scripts/ArchivePusher.js#L36-L37

Why is this needed at all? Shouldn't the addon be free from browser restrictions? Is this also needed for Zotero 7 addons?

Thanks!

Dan Stillman

unread,
May 29, 2024, 7:33:43 AMMay 29
to zoter...@googlegroups.com
I can't speak to what that plugin is doing, but HTTP requests from
plugins shouldn't be subject to same-origin restrictions, no.

XY Wong

unread,
May 29, 2024, 7:36:49 AMMay 29
to zotero-dev
The function you linked to (createCORSRequest) does nothing special but creates an XMLHttpRequest. There shouldn't be a CROS restriction for plugins in Zotero 6 or Zoter 7.

Btw, the plugin you mentioned is very old and is not a good example for developing new plugins. See the official example https://github.com/zotero/make-it-red

maie...@gmail.com

unread,
May 30, 2024, 4:21:37 AMMay 30
to zotero-dev
HTTP-Request work just fine in Plugins. There are a couple of plugins that use them, and it works.
Reply all
Reply to author
Forward
0 new messages