I have hosted angular 9 app on Amazon S3 as static website hosting and integrated with a OIDC authentication provider (OKTA) and Authorization grant with PKCE flow.
App is deployed successfully and when I click Login, my app gets redirected to okta for login, but when OKTA redirects using implicit/callback, my browser throw following error-
404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: implicit/callback
I have also used CloudFront to redirect http to https.
My application setup is:
Thanks Gary!
I was able to resolve this issue by following steps:
Wrote redirection rules in S3 bucket -
403 index.html 404 https www.mydomain.com #!/Updated the CloudFront behavior to forward the query strings by Selecting "Forward all, cache based on all" in CloudFront behavior for "Query String Forwarding and Caching"
Updated the Error document to index.html in CloudFront "Error Pages" for 403 and 404.
Adding following JavaScript to index.html file
<body>
<script>
var hash = window.location.hash;
const newHashpath = hash.replace("#!/",""); //(/#!(\/.*)$/.exec(window.location.pathname) || [])[1];
if (newHashpath) {
// history.replace(path);
window.history.pushState({},'',newHashpath);
}
</script>
<app-root></app-root>
</body>