1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: reload of admin/api page yields 404

fixes: #836
This commit is contained in:
Ivar Conradi Østhus 2021-05-05 09:01:39 +02:00
parent cafd497bd1
commit 37d701a121
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
3 changed files with 13 additions and 3 deletions

View File

@ -127,8 +127,8 @@ export default function getApp(
});
app.get(`${baseUriPath}/*`, (req, res) => {
if (req.path.includes('api')) {
res.status(404).send();
if (req.path.startsWith(`${baseUriPath}/api`)) {
res.status(404).send({ message: '404 - Not found' });
return;
}

View File

@ -16,6 +16,7 @@ unleash.start(
},
server: {
enableRequestLogger: true,
baseUriPath: '',
},
logLevel: LogLevel.debug,
enableOAS: true,

View File

@ -27,7 +27,16 @@ test('hitting a baseUri path returns HTML document', async t => {
test('hitting an api path that does not exist returns 404', async t => {
t.plan(0);
const request = await setupAppWithBaseUrl(stores);
await request.get('/hosted/api/i-dont-exist').expect(404);
await request.get('/api/i-dont-exist').expect(404);
});
test('hitting an /admin/api returns HTML document', async t => {
t.plan(0);
const request = await setupAppWithBaseUrl(stores);
await request
.get('/admin/api')
.expect(200)
.expect('Content-Type', 'text/html; charset=utf-8');
});
test('hitting a non-api returns HTML document', async t => {