Fix handling of root route when query params present

Signed-off-by: Adam Kunicki <kunickiaj@gmail.com>
This commit is contained in:
Adam Kunicki
2024-11-20 16:25:54 -08:00
parent db65221536
commit d66fa80907
3 changed files with 10 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-app-backend': patch
---
Fix root route handling when query parameters are present
@@ -93,9 +93,9 @@ describe('appPlugin', () => {
],
});
const rootContent = await fetch(`http://localhost:${server.port()}`).then(
res => res.text(),
);
const rootContent = await fetch(
`http://localhost:${server.port()}?foo=bar`,
).then(res => res.text());
expect(rootContent).toBe(`<html><head>
<script type="backstage.io/config">
+2 -1
View File
@@ -306,7 +306,8 @@ async function createEntryPointRouter({
const rootRouter = Router();
rootRouter.use((req, _res, next) => {
// Make sure / and /index.html are handled by the HTML5 route below
if (req.url === '/' || req.url === '/index.html') {
const urlWithoutQuery = req.url.split('?')[0];
if (urlWithoutQuery === '/' || urlWithoutQuery === '/index.html') {
next('router');
} else {
next();