Auth0 Home Blog Docs

How to troubleshoot failed request due to CORS?

custom-login
angular2
cors

#1

Error stack trace in Chrome:

polyfills.bundle.js:4297  XHR failed loading: POST "https://agugan.auth0.com/dbconnections/signup".
main.bundle.js:74  Error: null
Navigated to http://localhost:4200/login?

I couldnt understand why XHR is failing. I followed this example line by line:

https://github.com/auth0-samples/auth0-angularjs2-systemjs-sample/tree/master/02-Custom-Login

As additional information, my project was created using Angular CLI.


#2

According to the documentation there’s a specific log event type associated with a CORS failure so you should reproduce the situation and check the Logs section within your Dashboard for entries related to CORS. The log event type should be fco.

Finding an associated log event for a CORS failure may explain the underlying cause of the error. In general, these errors happen due to misconfiguration. For example, you have more than one client application and you configured your development URL for CORS in the incorrect client by mistake.


#3

@jmangelo no logs could be found .Its like the post call itself is not executed.But when tried with the custom-login-systemJS example of auth0, it works. I found out they are running using lite-server. But i am just using “ng serve” to start the development server. could it be possible because of the webserver? should i use explicit server. Thanks for answering…


#4

@jmangelo no logs could be found .Its like the post call itself is not executed.But when tried with the custom-login-systemJS example of auth0, it works. I found out they are running using lite-server. But i am just using “ng serve” to start the development server. could it be possible because of the webserver? should i use explicit server. Thanks for answering…


#5

The type of web server should not matter as the CORS failure is in an endpoint outside of your server /dbconnections/signup. As mentioned previously, most of the times this is caused by incorrect configuration and the logs will generally provide sufficient information. The fact that you don’t found logs makes this harder to troubleshoot.


#6