Hi Vipul,
I did test this with tomcat 8.5.69 using the Okta Hosted Angular Sample Application.
Here is what I did to get it to work.
For the ng build make sure to specify the application context you plan to use when deploying too tomcat.
ng build --base-href /oktahosted/
In the Angular modules.ts the path will not contain this application context, nor will the redirectUri passed when creating Okta provider. So for my app,
{
path: 'login/callback',
component: OktaCallbackComponent,
},
and
redirectUri: '/login/callback'
In tomcat in the webapps directory create your context (oktahosted
) folder and copy over all the files from the Angular dist
directory. Verify the index.html base href value is your context,
<base href="/oktahosted/">
Edit the tomcat …/conf/server.xml file and add the RewriteValve,
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
...
</Host>
Create a file …/conf/Catalina/localhost/rewrite.config in tomcat and add,
RewriteCond %{REQUEST_PATH} !-f
RewriteRule ^/oktahosted/(.*) /oktahosted/index.html
specifying your application context.
In Okta for your SPA application configuration, add a entry in Sign-in redirect URIs to include the application context your application will be deployed to.
http://localhost:8080/oktahosted/login/callback
You most likely will want to add an entry for the logout redirect URIs as well.
This is what I did in order to get our sample app to work. If you run into issues testing, open the browser dev tools, in the network tab make sure the values you expect to be passed in the /authorize call. Redirect URI that includes your application context,
http://localhost:8080/oktahosted/login/callback
In tomcat you should also be able to set the rewrite valve only for your application via WEB-INF, but I would try this setup first in order to get it working.