CORS issue with Couch/PouchDB connection

Having CORS issue with couchdb, can anyone assist?

I have db setup exactly as @Teodor’s tutorial

CORS is set to wildcard

image

I run the note page as per the tutorial but on dev console i am seeing a CORS error and pouch/couch is not synchronising (records can be added and updated in pouch)

I can connect to the couch database via the Admin Panel so i know it is running OK

I haven’t tried couch and pouch yet. I know from mobile and cors that wildcard domains don’t work if you are using credentials. Might be worth trying the actual domain and not the wildcard.

Hey Brian,
Can you try going to the couch Admin panel, then disable and enable CORS from there, does it make any difference?

No, tried that no luck
At 2am, in frustration, I removed wappler, wsppler beta and docker from my system and started again,. Now I can see the data in the dev console, I can add data but the BS table does not display any data,empty table
Something going very wrong but I think I need to take a break and come back later with a clear head

for info, rebuilt container again and turned off CORS. No change

Have you tried localhost:9913 instead *?

Have you tried turning it on instead for * through the admin panel? Also when you click on the error - are there any details?

i have laterally turned CORS on and off dozens of times, seems to have no effect

This is getting really weird

i now see two errors in the console

The first refers to port 9916 which confuses me as the container is running on 9913 and on clicking i simply get a site cant be reached error (to be expected as i don’t thing anything is running on that port)

Clicking the second (CORS) error i get this in the browser

{
instance_start_time: "1690538064",
db_name: "my_db",
purge_seq: "0-g1AAAABPeJzLYWBgYMpgTmHgzcvPy09JdcjLz8gvLskBCeexAEmGBiD1HwiyEhlwqEtkSKqHKMgCAIT2GV4",
update_seq: "9-g1AAAACLeJzLYWBgYMpgTmHgzcvPy09JdcjLz8gvLskBCeexAEmGBiD1HwiyMpgTmXOBAuymhmmmFmkm6HpwmJLIkFQP1c4G1m6YmGiSmpSGrjgLAAffKuo",
sizes: {
file: 74085,
external: 282,
active: 1601
},
props: { },
doc_del_count: 0,
doc_count: 1,
disk_format_version: 8,
compact_running: false,
cluster: {
q: 2,
n: 1,
w: 1,
r: 1
}
}

where are the config files stored so i can check for any errors. I can still access the db via the admin function without issue

In case this helps

I have done quite a bit of adding and deleting of containers etc while testing and gut feeling is there is some undeleted config settings lor duplication lurking in one of the configuration files but i cant find them.

I will try a different machine later to see if issue replicates

Could install Portainer locally and see what you have running, and on what ports, maybe do a tidy-up if there are unused containers running for some reason or other. Can be very useful.

Can you check the response headers when you visit the url http://localhost:9913/my_db in the browser.

http://127.0.0.1:9913/my_db/

gives

{

* instance_start_time: "1690538064",

* db_name: "my_db",

* purge_seq: "0-g1AAAABPeJzLYWBgYMpgTmHgzcvPy09JdcjLz8gvLskBCeexAEmGBiD1HwiyEhlwqEtkSKqHKMgCAIT2GV4",

* update_seq: "9-g1AAAACLeJzLYWBgYMpgTmHgzcvPy09JdcjLz8gvLskBCeexAEmGBiD1HwiyMpgTmXOBAuymhmmmFmkm6HpwmJLIkFQP1c4G1m6YmGiSmpSGrjgLAAffKuo",

* sizes:{
  * file: 74085,

  * external: 282,

  * active: 1601},

* props: { },

* doc_del_count: 0,

* doc_count: 1,

* disk_format_version: 8,

* compact_running: false,

* cluster:{
  * q: 2,

  * n: 1,

  * w: 1,

  * r: 1}

}#```

I want to know the response headers, you can see them in the network tab from devtools. It should contain the CORS headers that are being send from the server.

These?

1 Like

not sure is it helps but it is always “strict-origin-when-cross-origin” regardless of the settings of CORS, enabled or disabled

A lot is missing, not sure what goes wrong.

These are the headers I get with a database request:

Suggestions?

Can you test the following directly from the console

fetch('http://localhost:9913/my_db').then(response => response.json()).then(console.log).catch(console.error)