0

I am using AWS Cognito Hosted UI URL to login to my angular application. I am able to login successfully and receiving access token as well. I am able to redirect to localhost home page when I run my application locally.

https://hraXXXXXXXXX-XXXXXXXX-dev.auth.us-east-1.amazoncognito.com/login?client_id=XXXXXXXXXXXXXXXXXXXXXXXX&response_type=token&scope=aws.cognito.signin.user.admin+email+openid+phone+profile&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fadmin%2Fhome%2F

The above URL works fine and after logging in, it redirects to http://localhost:4200/admin/home

I am facing problem when I am changing the localhost to DNS. I have angular app which is hosted on S3 as static website. I am using Route 53 -> CloudFront -> S3 to access my angular application.

https://hrappXXXXXXXXXX-7aXXXXXXd-dev.auth.us-east-1.amazoncognito.com/login?client_id=XXXXXXXXXXXXXXXXXXXX&response_type=token&scope=aws.cognito.signin.user.admin+email+openid+phone+profile&redirect_uri=https%3A%2F%2FpXXXXXXXXXds.com%2Fadmin%2Fhome%2F

I am trying to redirect it to https://mydomain/admin/home

But I am getting follwing error.

[enter image description here](https://i.stack.imgur.com/ot9J4.png)

I have tried different solution but it is not working.

S3 bucket policy :

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<bucketname>/*"
        }
    ]
}

[enter image description here](https://i.stack.imgur.com/zeDk7.png)

My S3 has public access.

I have tried entering the indext.html in Default root object of cloud front. (https://serverfault.com/questions/581268/amazon-cloudfront-with-s3-access-denied)

But I am unable to figure out how to redirect to home page using domain name instead of local host.

Arpit Jain
  • 1,599
  • 9
  • 23

0 Answers0