Some APIs hit the CORS wall and others don't

Hello, I am really enjoying working on plugins but am hitting a wall when I try calling many APIs.

The problem is always the same. I send a GET request and get the error pasted below. Can anyone help me figure this out? I see many plugins that call the same APIs I get the below error on, so I know there’s a solution out there. I even set up a proxy server, but maybe I did it the wrong way.

CORS error:

Access to fetch at '...' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Thank you for any help you provide.

The Plugin runs in a restricted web browser which only able to origin:'null' in the request header, And some APIs block this kind of header so you see the error return. An approach is to call a CORS proxy which accept origin:'null' header instead of calling destination API directly.
For example: see https://corsproxy.io/ . but please be aware of data leaking since your data are sending to a 3rd proxy service in advance hitting the actual API.

1 Like