update middleware order

Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
Stephen Glass
2024-07-29 00:06:51 -04:00
parent 41b0d71313
commit 672a4b4876
2 changed files with 4 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2021 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+3 -6
View File
@@ -170,16 +170,13 @@ export async function createRouter(
userInfoDatabaseHandler,
});
router.use(createCookieAuthErrorMiddleware(appUrl, authUrl));
// Gives a more helpful error message than a plain 404
router.use('/:provider/', (req, _, next) => {
router.use('/:provider/', req => {
const { provider } = req.params;
if (provider.startsWith('.backstage')) {
return next('route');
}
throw new NotFoundError(`Unknown auth provider '${provider}'`);
});
router.use(createCookieAuthErrorMiddleware(appUrl, authUrl));
return router;
}