update middleware order
Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user