Okta redirect url throwing 404 in server

We are developing an angular application which consumes okta.
We have successfully done integration in localhost. While we hosted the application with tomcat server we are not able to land on the redirect url instead it throws 404 error as below

HTTP Status 404 - /stp-okta/home

type Status report

message /stp-okta/home

description The requested resource is not available.

Apache Tomcat/8.0.20

we have done the following settings in app.module.ts. Where application resides in stp-okta folder under webapps.

Below is the configuration which we have done in app.module.ts

issuer: 'https://dev-517712.okta.com/oauth2/default',
redirectUri: 'https://xxx.xxx.com/stp-okta/home',
clientId: '0oaim3ckl5JK1InwC123'

under app.routing.ts we have given the routing as below:
{ path: ‘’, component: HomeComponent ,canActivate:[OktaAuthGuard]},
{ path: ‘home’,component: OktaCallbackComponent},
{path: ‘’, redirectTo: ‘’, pathMatch: ‘full’ },
{ path: ‘**’, redirectTo: ‘’ }

export const routing = RouterModule.forRoot(appRoutes,{useHash:true});

My base path for the server is https://xxx.xxx.com/stp-okta

The below screenshot explains the setup okta in okta.


Kindly help resolving the issue.

You’ll have to configure Tomcat so it knows you’re serving up a SPA and everything redirects to index.html. We do this in JHipster with a ClientForwardController that sends all requests to the root.

Hi, mraible

Now it’s working fine when I added below code in confg/web.xml in tomcat serve. It’s correct tomcat not able to identify SPA application.

error-code 404 error-code
location /index.html location

I don’t think you can do this from web.xml. You have to have a custom filter for it.

Could you help with adding custom filter? I am creating an app and need a reference for the same

If you’re using hash-based routing, I believe your URL will be #home rather than /home. However, you can’t put hashes in redirect URIs, so that could create a problem. I found this, which might help: