Fix handling of root route when query params present
Signed-off-by: Adam Kunicki <kunickiaj@gmail.com>
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user