Skip to content

Commit

Permalink
Merge pull request #581 from archesproject/580_cors_error
Browse files Browse the repository at this point in the history
580 cors error
  • Loading branch information
whatisgalen authored Feb 20, 2020
2 parents 4247f94 + b365c64 commit 725a367
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 323 deletions.
3 changes: 3 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ PouchDB.plugin(PouchDBFind);
PouchDB.plugin(SqlLiteAdapter);

var adapter = 'cordova-sqlite';
var credentials = 'include';

// this is mostly just for testing but this shouldn't hurt anything by being in here
// as of this writing the cordova-plugin-sqlite-2 doesn't support the browser platform
if (!window.cordova || window.cordova.platformId === 'browser') {
adapter = 'idb';
credentials = 'omit';
}

var pouchDBs = (function() {
Expand Down Expand Up @@ -60,6 +62,7 @@ var pouchDBs = (function() {
});
this._projectDBs[projectId].remote = new PouchDB(server.url + '/couchdb/project_' + projectId, {
fetch: function (url, opts) {
opts.credentials = credentials;
opts.headers.set('authorization', 'Bearer ' + server.token);
return PouchDB.fetch(url, opts);
}
Expand Down
Loading

0 comments on commit 725a367

Please sign in to comment.