Issue Encountered:
Could never properly redirect back to our Angular2 application after successful social based authentication.
We were encountering a 404 (file not found) redirect issue in an Angular2 app after successfully authenticating via Google oAuth login. I was running my Angular application on Tomcat 9 and had the app running under an application context and not in the root (default-context> of the server. For example /example-application/index.html. The problem was the oAuth callback success url was set to /example-application/social-login-success?token= and you would just always get back a 404 error because the application/web server (Tomcat) was not able to retrieve a file at that location. That url is actually an Angular route that the angular router needs to handle, but the router was never being reached.Solution:
Add a redirect at the tomcat level.
1) Create a WEB-INF folder at location of your application root <Tomcat-root>/<example-application>/WEB-INF
2) Create a web.xml file within the new WEB-INF folder with the following content:
<web-app> <error-page> <error-code>404<error-code> </error-page> </web-app>
Comments
Post a Comment