aws-samples / aws-cdk-amplify-with-waf

enable WAF for Amplify Hosted web applications
MIT No Attribution
31 stars 17 forks source link

Issue with Next.js Amplify application (Cognito redirection not desired) #9

Closed theolrtpwc closed 4 months ago

theolrtpwc commented 5 months ago

Hi,

I've achieve to deploy your solution on top of our amplify application.

Amplify application is using --> Framework Next.js - SSR The issue is that I think our Next.js code should not redirect correctly to desired url.

What should I paste to my env var NEXTAUTH_URL ?

Before (=without your solution)
NEXTAUTH_URL = "ourcustomamplifydomain.com"

Now (=with your solution on top)

  1. NEXTAUTH_URL = "ourcustomamplifydomain.com" --> redirect to amplify url so get WebACL (not desired)
  2. NEXTAUTH_URL = "cloudfrontdistributiondomain.com" --> error 403 (not redirecting to signin page of cognito)

Maybe that should be an issue of configuration of Cognito user pool on our side (we have a Cognito domain, is it an issue ? that was working well with it before)

We kept our custom domain on amplifyapp.

In Cognito > App integration > User pool client > hosted UI > Allowed callback URLs --> I've tried to add all my url but not working :/ (before juste Amplify custom domain was needed)

Can you help on this please ?

theolrtpwc commented 4 months ago

Finally, with a call with multiples peoples of AWS, we've attend to fix the problem :