I have successfully used pages/api routes in previous versions of NextJS to connect to AWS API Gateway. I'm trying to use new app router to do the same thing in app/api/route. But I'm unable to get the aws-amplify
libraries working, i.e.
const {Auth: ssrAuth} = withSSRContext({ req: request }); //works
const user = await ssrAuth.currentAuthenticatedUser(); //fails
This works fine with page router and I'm able to get the user token to attach the authorizer to the API Gateway request.
Any idea why? The request is there and I can see the cookie with the user token. What am I doing wrong?
Any feedback/tip much appreciated