# Implicit Callback issue for Angular failing to load css, js, … all assets when base url in index.html

**URL:** <https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682>\
**Category:** Questions\
**Created:** [January 16, 2020, 4:28pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682 "2020-01-16T16:28:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![taz](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@taz](https://devforum.okta.com/u/taz)\
**Post date:** [January 16, 2020, 4:28pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/1 "2020-01-16T16:28:22Z")

</div>

Hi,  
I have an angular 8 application and i have implemented Okta into my application using the example [here](https://github.com/okta/samples-js-angular/tree/master/okta-hosted-login). I am able to be redirected to Okta Login but when the redirect happens, the URL is :“[http://localhost:4200/authorization-code/assets/scss/bootstrap.min.css](http://localhost:4200/authorization-code/assets/scss/bootstrap.min.css)” As you can see an excess “authorization-code” is added at the end. That fails as the redirect URL should just be [http://localhost:4200](http://localhost:4200). All resources are trying to be fetched from localhost:4200/authorization-code/main.js and all other files which fail.

My base-href :   
Redirect URI : document.getElementsByTagName(‘base’)[0].href + ‘authorization-code/callback’,

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/2/2c76d9621c28ead2439a31000aba549bc1d4cca9.png)

please let me know if i am missing something.  
thanks

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [January 16, 2020, 4:30pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/2 "2020-01-16T16:30:31Z")

</div>

Can you try adding `<base href="/" />` to the top of your `index.html` and see if that helps?

---

<div class="post-metadata">

**Author:** ![taz](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@taz](https://devforum.okta.com/u/taz)\
**Post date:** [January 16, 2020, 4:34pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/3 "2020-01-16T16:34:02Z")

</div>

I tired adding that and got the same result.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [January 16, 2020, 5:30pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/4 "2020-01-16T17:30:20Z")

</div>

Can you try hard-coding your redirect URI to `http://localhost:4200`? If that works, you should be able to use `window.location.origin + '/authorization-code/callback'`.

---

<div class="post-metadata">

**Author:** ![taz](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@taz](https://devforum.okta.com/u/taz)\
**Post date:** [January 16, 2020, 6:22pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/5 "2020-01-16T18:22:05Z")

</div>

@mraible I tried hardcoding ‘[http://localhost:4200/authorization-code/callback](http://localhost:4200/authorization-code/callback)’ but got the same issue. I even tried setting the redirect URI manually by adding this “this.oktaAuth.setFromUri(‘[http://localhost:4200/](http://localhost:4200/)’);” in my app component but event this is ignored. I tried interceptor but those wont work as main.js cant be loaded.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [January 17, 2020, 8:27pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/6 "2020-01-17T20:27:37Z")

</div>

I was able to get the sample you mentioned working with `authorization-code/callback`. Here’s how:

```auto
git clone https://github.com/okta/samples-js-angular.git
cd samples-js-angular/okta-hosted-login

```

Then I created an app on Okta with `http://localhost:8080/authorization-code/callback` as a login redirect URI.

 ![spa-app](https://global.discourse-cdn.com/oktadev/original/2X/c/c67ebbe3f193d7d0e25c4e5532c78a774d4089d8.png)

Next, I created a `testenv` file in the `samples-js-angular` directory.

```auto
ISSUER=https://dev-133320.okta.com/oauth2/default
CLIENT_ID=0oa2ixujp77hbMZcU357

```

Then I changed `src/app/app.config` and `app.module.ts` to use this new redirectUri.

```diff
--- a/okta-hosted-login/src/app/app.config.ts
+++ b/okta-hosted-login/src/app/app.config.ts
@@ -4,7 +4,7 @@ export default {
   oidc: {
     clientId: `${CLIENT_ID}`,
     issuer: `${ISSUER}`,
- redirectUri: 'http://localhost:8080/implicit/callback',
+ redirectUri: 'http://localhost:8080/authorization-code/callback',
     scopes: ['openid', 'profile', 'email'],
     pkce: true,
     testing: {
diff --git a/okta-hosted-login/src/app/app.module.ts b/okta-hosted-login/src/app/app.module.ts
index e3affe7..d48b5f3 100644
--- a/okta-hosted-login/src/app/app.module.ts
+++ b/okta-hosted-login/src/app/app.module.ts
@@ -34,7 +34,7 @@ const appRoutes: Routes = [
     component: HomeComponent,
   },
   {
- path: 'implicit/callback',
+ path: 'authorization-code/callback',
     component: OktaCallbackComponent,
   },

```

After that, I ran `ng serve` and was able to successfully login.

---

<div class="post-metadata">

**Author:** ![taz](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@taz](https://devforum.okta.com/u/taz)\
**Post date:** [January 20, 2020, 8:25pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/7 "2020-01-20T20:25:07Z")

</div>

Everyone, i was able to resolve this issue. It turned out to be Location Strategy in my route file. Apparently Okta call back route is not hashed and that makes sense. So if you removed Location Strategy in providers from the app.routing.ts, app loaded fine. Thanks guys.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [January 21, 2020, 12:55am UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/8 "2020-01-21T00:55:43Z")

</div>

Thanks for replying and letting us know how you fixed it!

---

<div class="post-metadata">

**Author:** ![naveen800](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@naveen800](https://devforum.okta.com/u/naveen800)\
**Post date:** [April 3, 2020, 4:07pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/9 "2020-04-03T16:07:22Z")

</div>

@mraible, can you please help me out with similiar situation, my localhost is working as expected but when i delpoy code on PROD receiving error message.

Note: Code deployed on Apache HTTPD server

1. Login works as expected
2. redirect to OKTA login page
3. After signin from OKTA received below error message

Not Found  
The requested URL /archivedb/implicit/callback was not found on this server.Error: Cannot match any routes. URL Segment: ‘implicit/callback’

---

<div class="post-metadata">

**Author:** ![tharun\_97](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tharun\_97](https://devforum.okta.com/u/tharun_97)\
**Post date:** [April 25, 2020, 1:51pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/10 "2020-04-25T13:51:12Z")

</div>

i am facing the same issues did you solved it

---

<div class="post-metadata">

**Author:** ![naveen800](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@naveen800](https://devforum.okta.com/u/naveen800)\
**Post date:** [April 25, 2020, 4:51pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/11 "2020-04-25T16:51:48Z")

</div>

Followed this thread and which resolved my issues:

> [@Configuring the Angular router to \`useHash: true\` breaks \`OktaAuthService.loginRedirect\`](https://devforum.okta.com/t/configuring-the-angular-router-to-usehash-true-breaks-oktaauthservice-loginredirect/7374/3):
>
> We have the same issue, on a new Application. Issue was reported on December. Do we have any feedback on this issue? Any ideas for fixing the problem? Quit important as we need to move our existing App from Cognito AWS to OKTA, thus we need to find a solution. Thanks in advance for any feedback!

Github - [GitHub - beyondJohn/OktaAngularIntegration: Using Okta OAuth to secure an Angular 8 app using {useHash:true} routing strategy](https://github.com/beyondJohn/OktaAngularIntegration)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 23, 2024, 11:21pm UTC](https://devforum.okta.com/t/implicit-callback-issue-for-angular-failing-to-load-css-js-all-assets-when-base-url-in-index-html/7682/12 "2024-01-23T23:21:29Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
