I got this error: blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

I have made the ai2 running on my own server.
When i try to connect companion by WIFI, it fails, and I got this error:

Access to XMLHttpRequest at 'http://192.168.0.102:8001/_newblocks' from origin 'http://x.x.x.x:8888' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

So where should I change to add this Access-Control-Allow-Origin header?
Thanks

Is this helpful?

the problem is I don't know where/which file to put this line in:

res.setHeader("Access-Control-Allow-Origin", "*");

It looks like you are using Chrome. Unfortunately, Chrome is making a change that prevents websites on public IPs from accessing services on private IPs, such as your local network. There is a temporary workaround you can try in the settings but this will disappear in a future version of Chrome. Alternatively, switch to using Firefox to avoid the unilateral change by Google.

1 Like

Thanks Evan.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.