-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Hi, I found an issue when trying to setup Frontegg middleware with Next.js as described in the documentation. There seems to be a problem when checking whether given route is frontegg public route here, but only when isFronteggPublicRoute function is called from fronteggNextJs middleware. I also tried to setup express app with frontegg middleware and it works correctly.
Actual behaviour
- following API requests sent from login screen fail with status code 401
- /api/frontegg/metadata?entityName=saml
- /api/frontegg/identity/resources/sso/v1
- /api/frontegg/identity/resources/configurations/v1/public
- user is not able to log in to the app using login form
Expected behaviour
- requests to public API mentioned above succeed with status code 200
- login flow works correctly
For now, we are using following workaround to make fronteggNextJs middleware work:
export default (req: NextApiRequest, res: NextApiResponse) => {
// we had to remove `/api/frontegg` part
// of `req.url` to make it work correctly
req.url = req.url.replace('/api/frontegg', '')
return fronteggNextJs({
clientId: process.env.FRONTEGG_CLIENT_ID,
apiKey: process.env.FRONTEGG_API_KEY,
authMiddleware: withAuthentication(),
contextResolver: async (req) => {
return {
tenantId: req.user ? req.user.tenantId : '',
userId: req.user ? req.user.id : '',
permissions: [FronteggPermissions.All],
}
},
})(req, res)
}davidklemme and verhulstd
Metadata
Metadata
Assignees
Labels
No labels