vrtmrz / obsidian-livesync

MIT License
4.7k stars 151 forks source link

Blocked by CORS policy #297

Open Adrianna20 opened 1 year ago

Adrianna20 commented 1 year ago

Abstract

The synchronisation failed after saying TypeError:Failed to fetch.

Expected behaviour

Actually happened

On OSX: Everything works fine after the first setup, then everytime I restart the APP, it will show this error "TypeError:Failed to fetch.". In Dev Log, its said: Access to fetch at 'https://xxx.com/obsidian-sync-1/' from origin 'app://obsidian.md' has been blocked by CORS policy

On iPhone and iPad, they are successfully synced everytime.

sevenights commented 12 months ago

Facing the same problem. IPad sync as expected, works in both direction. But on windows pc, the plugin can only download the file from server, like DB->Storage, while it cannot upload the local changes to the couchDB server.

vrtmrz commented 12 months ago

Thank you for opening this issue! I think that may the CORS host of the response seems something weird.

Could you please check the remote database configuration by the Check database configuration feature? It can be performed from the Remote database configuration pane on the setting dialogue. As another possibility, if you have configured a proxy for the CouchDB, make sure that it has not touched the host header while in response. If the CouchDB has been configured correctly, the appropriate host will automatically be selected from the configuration values.

DB->Storage

A bit longer explanation, but let me write it down. (In short word, we need a correct replication to make DB->Storage meaningful, but seems to be lacking). Even if it is for the small log area, I know that it sounds like I am playing word games and sorry for the complication. However, this does not always mean "could be downloaded". In this message, DB is pointing to the Local Database which is synchronised (or will be synchronised) with the Remote database. This is a counterpart of Storage->DB. Storage changes applied to the local database, the local database will be replicated to the remote database in the replication. At that time, replicated changes which came from other devices will be also replicated to the local database. As a result, it will be applied to the local storage (or detected as conflict and you could make the decision).

We therefore need to check that the changes are actually transferred. I am worried that some changes have not been synced...