From bd136fa2a2281c0a1d6865ed751cfda805641477 Mon Sep 17 00:00:00 2001 From: Richard Petersen <richard.petersen@open-xchange.com> Date: Mon, 28 Feb 2022 16:47:51 +0100 Subject: [PATCH] Fix: OXUIB-1378 - 7.10.x share links don't work with 8.0 Root cause: There are middlewares, which still use old redirects to /ui Solution: To prevent 404s, we just serve the index.html --- spec/file_caching_test.js | 7 +++++++ src/createApp.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/spec/file_caching_test.js b/spec/file_caching_test.js index 71c7981..c9004fb 100644 --- a/spec/file_caching_test.js +++ b/spec/file_caching_test.js @@ -76,6 +76,13 @@ 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/src/createApp.js b/src/createApp.js index 9ca9690..7e9434e 100644 --- a/src/createApp.js +++ b/src/createApp.js @@ -111,6 +111,15 @@ export function createApp () { next() }) + // backwards compatibility for 7.10.x + // 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() + }) + app.post('/redirect', (req, res, next) => { const location = req.body.location || '../busy.html' res.redirect(location) -- GitLab