Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Cors error. Using Anki 2.1.49. #372

Open
joaquintoral opened this issue Jan 3, 2023 · 3 comments
Open

Cors error. Using Anki 2.1.49. #372

joaquintoral opened this issue Jan 3, 2023 · 3 comments

Comments

@joaquintoral
Copy link

I'm getting this error

Access to XMLHttpRequest at 'http://localhost:8765/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost' that is not equal to the supplied origin.

This is what my anki-connect config.js looks like

{ "apiKey": null, "apiLogPath": null, "ignoreOriginList": [], "webBindAddress": "127.0.0.1", "webBindPort": 8765, "webCorsOrigin": "http://localhost", "webCorsOriginList": [ "http://localhost", null ] }

I've been experimenting on this for the whole day, but I can't seem to figure out why Anki still won't allow me to pull data from Anki Connect.

@andreaskienle
Copy link
Contributor

Can you try adding "http://localhost:3000" and/or "http://localhost:8765" to the webCorsOriginList array?

{ "apiKey": null, "apiLogPath": null, "ignoreOriginList": [], "webBindAddress": "127.0.0.1", "webBindPort": 8765, "webCorsOrigin": "http://localhost", "webCorsOriginList": [ "http://localhost", null, "http://localhost:8765", "http://localhost:3000"] }

@joaquintoral
Copy link
Author

joaquintoral commented Feb 13, 2023

Can you try adding "http://localhost:3000" and/or "http://localhost:8765" to the webCorsOriginList array?

{ "apiKey": null, "apiLogPath": null, "ignoreOriginList": [], "webBindAddress": "127.0.0.1", "webBindPort": 8765, "webCorsOrigin": "http://localhost", "webCorsOriginList": [ "http://localhost", null, "http://localhost:8765", "http://localhost:3000"] }

I did try that. But it didn't work. I had to edit the add-on code and add the URLs there instead.

@andreaskienle
Copy link
Contributor

Ok, that's weird. For me this always does the trick.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants