Localhost and CORS with Auth0 not allowing me to login

守給你的承諾、 提交于 2021-02-20 19:04:32

问题


I'm making a React app and trying to use Auth0 to authenticate. After trying to log in, it returns this:

XMLHttpRequest cannot load https://my-domain.auth0.com/usernamepassword/login. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

I thought it would be related to this: CORS problems with Auth0 and React but I have both http://localhost:3000, http://localhost:3000/login in the 'Allowed Origins (CORS)' spot in Auth0's settings (and yes I'm using the correct client ID as well).

I tried putting http://localhost:3000/, http://localhost:3000/login in the 'Allowed Callback URL's (don't know exactly what that does) but that didn't work either.

When I use the social connection (Google) it allowed me to login after putting http://localhost:3000/login in the Allowed Callback URL's.

But it still won't work for just a new user logging in.

Any help?

If it makes a difference:

  • Auth0 Logs show for the social login but there are no logs at all for when I connect otherwise

  • I think related to this is that I also get this every time I load the page:

    There was an error fetching the SSO data. This could simply mean that there was a problem with the network. But, if a "Origin" error has been logged before this warning, please add "http://localhost:3000" to the "Allowed Origins (CORS)" list in the Auth0 dashboard: ...(link to my dash)

  • I get a 404 from the gravatar website

  • Also I get these errors (may not be related):

Refused to set unsafe header "accept-encoding"

Refused to set unsafe header "user-agent"


回答1:


Something was wrong with the client in Auth0. I don't know what it was but I built an Angular4 app and connected to the same client in Auth0 and got the same errors. I then tried deleting the client in Auth0 and making a new one and now it works. I have no idea what was causing the error, but creating a new client and connecting to that one fixed the issue.



来源:https://stackoverflow.com/questions/43104380/localhost-and-cors-with-auth0-not-allowing-me-to-login

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!