diff --git a/services/web/frontend/js/features/pdf-preview/util/output-files.js b/services/web/frontend/js/features/pdf-preview/util/output-files.js index 136fbdb47c..eb3c05c7a9 100644 --- a/services/web/frontend/js/features/pdf-preview/util/output-files.js +++ b/services/web/frontend/js/features/pdf-preview/util/output-files.js @@ -80,7 +80,9 @@ export const handleOutputFiles = async (projectId, data) => { const logFile = outputFiles.get('output.log') if (logFile) { - const response = await fetch(`${logFile.url}?${params}`) + const response = await fetch( + `${data.pdfDownloadDomain}${logFile.url}?${params}` + ) const log = await response.text() @@ -96,7 +98,9 @@ export const handleOutputFiles = async (projectId, data) => { const blgFile = outputFiles.get('output.blg') if (blgFile) { - const response = await fetch(`${blgFile.url}?${params}`) + const response = await fetch( + `${data.pdfDownloadDomain}${blgFile.url}?${params}` + ) const log = await response.text() diff --git a/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js b/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js index 0f9235c3a7..66efe43d9e 100644 --- a/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js +++ b/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js @@ -57,7 +57,7 @@ const mockCompile = () => status: 'success', clsiServerId: 'foo', compileGroup: 'priority', - pdfDownloadDomain: '', + pdfDownloadDomain: 'https://clsi.test-overleaf.com', outputFiles: cloneDeep(outputFiles), }, }) @@ -85,7 +85,7 @@ const mockClearCache = () => fetchMock.delete('express:/project/:projectId/output', 204) const mockValidPdf = () => { - nock('https://www.test-overleaf.com') + nock('https://clsi.test-overleaf.com') .get(/^\/build\/output\.pdf/) .replyWithFile(200, examplePDF) } @@ -117,7 +117,17 @@ LaTeX Font Info: External font \`cmex10' loaded for size `, } -const mockBuildFile = (responses = defaultFileResponses) => +const mockBuildFile = (responses = defaultFileResponses) => { + fetchMock.get('begin:https://clsi.test-overleaf.com/', _url => { + const url = new URL(_url, 'https://clsi.test-overleaf.com') + + if (url.pathname in responses) { + return responses[url.pathname] + } + + return 404 + }) + fetchMock.get('express:/build/:file', (_url, options, request) => { const url = new URL(_url, 'https://example.com') @@ -127,6 +137,7 @@ const mockBuildFile = (responses = defaultFileResponses) => return 404 }) +} const storeAndFireEvent = (key, value) => { localStorage.setItem(key, value) @@ -378,7 +389,8 @@ describe('', function () { screen.getByText('Conflicting Paths Found') expect(fetchMock.called('express:/project/:projectId/compile')).to.be.true // TODO: auto_compile query param - expect(fetchMock.called('express:/build/:file')).to.be.false // TODO: actual path + expect(fetchMock.called('begin:https://clsi.test-overleaf.com/')).to.be + .false // TODO: actual path }) it('sends a clear cache request when the button is pressed', async function () { @@ -412,7 +424,7 @@ describe('', function () { }) expect(fetchMock.called('express:/project/:projectId/compile')).to.be.true // TODO: auto_compile query param - expect(fetchMock.called('express:/build/:file')).to.be.true // TODO: actual path + expect(fetchMock.called('begin:https://clsi.test-overleaf.com/')).to.be.true // TODO: actual path }) it('handle "recompile from scratch"', async function () { @@ -454,7 +466,7 @@ describe('', function () { expect(fetchMock.called('express:/project/:projectId/compile')).to.be.true // TODO: auto_compile query param expect(fetchMock.called('express:/project/:projectId/output')).to.be.true - expect(fetchMock.called('express:/build/:file')).to.be.true // TODO: actual path + expect(fetchMock.called('begin:https://clsi.test-overleaf.com/')).to.be.true // TODO: actual path }) it('shows an error for an invalid URL', async function () {