# Angular ng build. http://localhost:4200/implicit/callback error 404

**URL:** <https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202>\
**Category:** Questions\
**Created:** [May 2, 2020, 2:40pm UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202 "2020-05-02T14:40:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [May 2, 2020, 2:40pm UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/1 "2020-05-02T14:40:36Z")

</div>

Hi all! I created my Angular app using Okta Sign-In Widget. Everything works fine in development mode, when I use` ng serve` command.  
Then I created a build using `ng build` command and ran it locally using simple Express NodeJS server. Application works fine but when I try to login, after I enter login and password and push login button - I get an error like  
GET [http://localhost:4200/implicit/callback?code=SxQzTxWeFZqmKmd3ENgE&state=jnQivLfhxBZ9253DgPbqYSrn4Bi2KRMyXeHeBfsiNc93s2eBX3qg1sTHsEsWENo9](http://localhost:4200/implicit/callback?code=SxQzTxWeFZqmKmd3ENgE&state=jnQivLfhxBZ9253DgPbqYSrn4Bi2KRMyXeHeBfsiNc93s2eBX3qg1sTHsEsWENo9) 404 (Not Found).  
All okta config is hardcoded in ts file in src folder. I do not use any external files (like testenv).  
Origin URL is the same in development mode and on my server ([http://localhost:4200/](http://localhost:4200/))  
What can be wrong?

---

<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:** [May 2, 2020, 3:48pm UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/2 "2020-05-02T15:48:56Z")

</div>

You have to configure your web server so it’s SPA-aware. That is, all routes should go to index.html. There’s lots of tutorials on how to do this, just google for “$webserver spa”. For example [express.js spa](https://www.google.com/search?q=express.js+spa).

---

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [May 2, 2020, 4:26pm UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/3 "2020-05-02T16:26:26Z")

</div>

Thank you very much! This is the key moment: `app.get('/',...` should be changed to` app.get('*',`

```
// handle every other route with index.html, which will contain
// a script tag to your application's JavaScript file(s).
app.get('*', function (request, response) {
    response.sendFile(path.resolve(__dirname, 'index.html'));
});
```

---

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [May 15, 2020, 9:42pm UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/4 "2020-05-15T21:42:59Z")

</div>

Login worked fine from localhost. But I get ERR\_CONNECTION\_TIMED\_OUT when I deployed my app on a real Internet server.  
In Network requests I see warning “Provisional headers are shown”.  
I deployed my app here [https://your-favorite-places.ew.r.appspot.com](https://your-favorite-places.ew.r.appspot.com)  
Here are my app settings  
 ![123](https://global.discourse-cdn.com/oktadev/original/2X/f/f764f2feb0f15e2e8a532dfb8f5d644a0890656e.jpeg)  
Here my CORS settings

 ![124](https://global.discourse-cdn.com/oktadev/original/2X/0/0bbb665939e77a7006a5ae4fdcd4b66aff46824e.jpeg)  
In oidc I changed redirectUri from ‘[http://localhost:4200/implicit/callback](http://localhost:4200/implicit/callback)’ to ‘[https://your-favorite-places.ew.r.appspot.com:8081/implicit/callback](https://your-favorite-places.ew.r.appspot.com:8081/implicit/callback)’.  
Here is a test account for your help:  
login: [stipe\_miocic@test.com](mailto:stipe_miocic@test.com)  
pass: 123456789Nn  
Could anybody help me?

---

<div class="post-metadata">

**Author:** ![vijet](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/vijet/32/245_2.png) [@vijet](https://devforum.okta.com/u/vijet)\
**Post date:** [May 16, 2020, 4:41am UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/5 "2020-05-16T04:41:52Z")

</div>

Hi @TermenVox,

Why is your redirect\_uri `https://your-favorite-places.ew.r.appspot.com:8081/implicit/callback`? i.e. why is the port 8081 in the redirect URI? Shouldn’t it be `https://your-favorite-places.ew.r.appspot.com/implicit/callback`?

Looking at the network requests made by your app, the /authorize call is successfully redirecting back with the authorization code (which will then be exchanged for an access token)  
But the page `https://your-favorite-places.ew.r.appspot.com:8081/implicit/callback` is timing out which could mean that this route is not valid in your deployed application.

 ![timeout](https://global.discourse-cdn.com/oktadev/original/2X/a/a914329b9a20bdbb28bea978c0f45741a1c73e79.jpeg)

Change your redirect uri to `https://your-favorite-places.ew.r.appspot.com/implicit/callback` and it should work, most likely.  
You should do this both in your app code, and okta app configuration.

---

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [May 16, 2020, 9:56am UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/6 "2020-05-16T09:56:11Z")

</div>

Thank you very much! It works!

---

<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 24, 2024, 7:30pm UTC](https://devforum.okta.com/t/angular-ng-build-http-localhost-4200-implicit-callback-error-404/9202/7 "2024-01-24T19:30:23Z")

</div>

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