简体   繁体   English

将 AWS-Amplify 与 Firefox 一起使用

[英]Using AWS-Amplify with Firefox

I hope you are all doing good,我希望你们都做得很好

I have a question that I've been stuck on for the past couple of days.我有一个问题,在过去的几天里我一直在纠结。 I am building a website with React that uses AWS-Amplify for user authentications (For users on the Cognito AWS database).我正在使用 React 构建一个网站,该网站使用 AWS-Amplify 进行用户身份验证(对于 Cognito AWS 数据库上的用户)。

I am working on the Log-in and Sign-up page, and it's working fine when using Chrome, but whenever I am using Firefox there is an issue (Specifically the Log-in).我正在登录和注册页面上工作,使用 Chrome 时它运行良好,但每当我使用 Firefox 时,都会出现问题(特别是登录)。

Problem: There is a part in the JS code that uses the Auth.signin() function from the aws-amplify extension.问题: JS 代码中有一部分使用来自 aws-amplify 扩展的 Auth.signin() function。 This function takes in the username and password and returns if the user is authenticated or not.这个 function 接受用户名和密码,并返回用户是否通过身份验证。 However, when using Firefox, this function gets timed-out, as if the browser can't get the response from the server.但是,当使用 Firefox 时,这个 function 会超时,就好像浏览器无法得到服务器的响应一样。 Here is a screenshot of the console:这是控制台的屏幕截图:

在此处输入图像描述

Seems like the response is 403 but I am guessing it's because of the time-out.似乎响应是 403 但我猜这是因为超时。 (The try/catch doesn't catch anything because it looks as if the page freezes) (try/catch 没有捕获任何东西,因为它看起来好像页面冻结了)

I hope I made it clear, and thank you for your time reading everything!我希望我说清楚了,感谢您花时间阅读所有内容!

Do your request headers/body contain the correct username and password for the user in Firefox, and is it sending the request to the same endpoint as in Chrome?您的请求标头/正文是否包含 Firefox 中用户的正确用户名和密码,并且它是否将请求发送到与 Chrome 中相同的端点? The 403 code makes me think that the endpoint is malformed on the Firefox request. 403 代码让我认为端点在 Firefox 请求上格式错误。 Finally, is it sending with SRP_AUTH or USER_PASSWORD_AUTH ?最后,是使用SRP_AUTH还是USER_PASSWORD_AUTH发送?

Also, since you're using React with Cognito+Amplify for auth*, you might want to consider using the withAuthenticator higher-order-component provided by aws-amplify-react and styling it to your needs.此外,由于您将 React 与 Cognito+Amplify 一起用于 auth*,因此您可能需要考虑使用aws-amplify-react提供的withAuthenticator高阶组件并根据您的需要对其进行样式设置。 Then you won't need to maintain your own login logic, won't need to worry about fixing it yourself if a browser change breaks your code, etc.然后,您无需维护自己的登录逻辑,如果浏览器更改破坏了您的代码等,您无需担心自己修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM