From ded6af8a6b3e7384970ae036ddf21a8301de98cb Mon Sep 17 00:00:00 2001 From: Richard Petersen <richard.petersen@open-xchange.com> Date: Tue, 1 Mar 2022 10:56:06 +0100 Subject: [PATCH] Fix: OXUIB-1378 - 7.10.x share links don't work with 8.0 (2) Use redirect instead of delivering index.html to prevent /ui paths in the future --- spec/file_caching_test.js | 7 ------- spec/redirect_test.js | 6 ++++++ src/createApp.js | 4 +--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/spec/file_caching_test.js b/spec/file_caching_test.js index c9004fb..71c7981 100644 --- a/spec/file_caching_test.js +++ b/spec/file_caching_test.js @@ -76,13 +76,6 @@ describe('File caching service', function () { expect(response.text).to.equal('<html><head></head><body>it\'s me</body></html>') }) - it('serves /ui as index.html', async function () { - const response = await request(app).get('/ui') - expect(response.statusCode).to.equal(200) - expect(response.headers['content-type']).to.equal('text/html') - expect(response.text).to.equal('<html><head></head><body>it\'s me</body></html>') - }) - it('adds / to dependencies', async function () { const response = await request(app).get('/dependencies') expect(response.statusCode).to.equal(200) diff --git a/spec/redirect_test.js b/spec/redirect_test.js index c58060b..1981c7d 100644 --- a/spec/redirect_test.js +++ b/spec/redirect_test.js @@ -32,4 +32,10 @@ describe('Redirects', function () { expect(response.statusCode).to.equal(302) expect(response.headers.location).to.equal('/appsuite/whatever/path') }) + + it('redirects /ui to /', async function () { + const response = await request(app).get('/ui') + expect(response.statusCode).to.equal(302) + expect(response.headers.location).to.equal('/') + }) }) diff --git a/src/createApp.js b/src/createApp.js index 7e9434e..165eca8 100644 --- a/src/createApp.js +++ b/src/createApp.js @@ -115,9 +115,7 @@ export function createApp () { // this should hopefully be resolved with an ingress // or proper config. But is used to be safe on all ends app.get('/ui', async (req, res, next) => { - const { 'content-type': contentType, content } = fileCache.get('/index.html') - if (content) return res.setHeader('content-type', contentType).status(200).send(content) - next() + res.redirect(process.env.APP_ROOT) }) app.post('/redirect', (req, res, next) => { -- GitLab