Skip to content

Commit

Permalink
Merge pull request #1362 from cdrini/br-cors
Browse files Browse the repository at this point in the history
Pass forward credentials for protected books
  • Loading branch information
cdrini authored Dec 3, 2024
2 parents 9bd4393 + 620a838 commit 05c23e8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/plugins/plugin.text_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export class TextSelectionPlugin {
url: applyVariables(this.options.fullDjvuXmlUrl, this.optionVariables),
dataType: this.options.jsonp ? "jsonp" : "html",
cache: true,
xhrFields: {
withCredentials: window.br.protected,
},
error: (e) => undefined,
}).then((res) => {
try {
Expand All @@ -115,6 +118,9 @@ export class TextSelectionPlugin {
url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }),
dataType: this.options.jsonp ? "jsonp" : "html",
cache: true,
xhrFields: {
withCredentials: window.br.protected,
},
error: (e) => undefined,
});
try {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/search/plugin.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ BookReader.prototype.search = async function(term = '', overrides = {}) {
callSearchResultsCallback(await $.ajax({
url: url,
cache: true,
xhrFields: {
withCredentials: this.protected,
},
beforeSend: xhr => { this.searchXHR = xhr; },
}));
};
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/tts/PageChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default class PageChunk {
type: 'GET',
url: `https://${server}/BookReader/BookReaderGetTextWrapper.php`,
cache: true,
xhrFields: {
withCredentials: window.br.protected,
},
data: {
path: `${bookPath}_djvu.xml`,
page: leafIndex,
Expand Down
2 changes: 1 addition & 1 deletion tests/jest/plugins/plugin.text_selection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const FAKE_XML_EMPTY = '';

describe("Generic tests", () => {
document.body.innerHTML = '<div id="BookReader">';
const br = new BookreaderWithTextSelection({
const br = window.br = new BookreaderWithTextSelection({
data: [
[
{ width: 800, height: 1200,
Expand Down

0 comments on commit 05c23e8

Please sign in to comment.