Skip to content

Commit 05c23e8

Browse files
authored
Merge pull request #1362 from cdrini/br-cors
Pass forward credentials for protected books
2 parents 9bd4393 + 620a838 commit 05c23e8

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/plugins/plugin.text_selection.js

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ export class TextSelectionPlugin {
8989
url: applyVariables(this.options.fullDjvuXmlUrl, this.optionVariables),
9090
dataType: this.options.jsonp ? "jsonp" : "html",
9191
cache: true,
92+
xhrFields: {
93+
withCredentials: window.br.protected,
94+
},
9295
error: (e) => undefined,
9396
}).then((res) => {
9497
try {
@@ -115,6 +118,9 @@ export class TextSelectionPlugin {
115118
url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }),
116119
dataType: this.options.jsonp ? "jsonp" : "html",
117120
cache: true,
121+
xhrFields: {
122+
withCredentials: window.br.protected,
123+
},
118124
error: (e) => undefined,
119125
});
120126
try {

src/plugins/search/plugin.search.js

+3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ BookReader.prototype.search = async function(term = '', overrides = {}) {
223223
callSearchResultsCallback(await $.ajax({
224224
url: url,
225225
cache: true,
226+
xhrFields: {
227+
withCredentials: this.protected,
228+
},
226229
beforeSend: xhr => { this.searchXHR = xhr; },
227230
}));
228231
};

src/plugins/tts/PageChunk.js

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export default class PageChunk {
2626
type: 'GET',
2727
url: `https://${server}/BookReader/BookReaderGetTextWrapper.php`,
2828
cache: true,
29+
xhrFields: {
30+
withCredentials: window.br.protected,
31+
},
2932
data: {
3033
path: `${bookPath}_djvu.xml`,
3134
page: leafIndex,

tests/jest/plugins/plugin.text_selection.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const FAKE_XML_EMPTY = '';
8787

8888
describe("Generic tests", () => {
8989
document.body.innerHTML = '<div id="BookReader">';
90-
const br = new BookreaderWithTextSelection({
90+
const br = window.br = new BookreaderWithTextSelection({
9191
data: [
9292
[
9393
{ width: 800, height: 1200,

0 commit comments

Comments
 (0)