# RedirectURI causes error in Angular Deployment

**URL:** <https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196>\
**Category:** Questions\
**Created:** [March 5, 2021, 4:14am UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196 "2021-03-05T04:14:35Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 5, 2021, 4:14am UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/1 "2021-03-05T04:14:35Z")

</div>

Has anyone else had issues using the RedirectURI in an Angular deployed environment with IIS? I was able to create an application that uses the OKTAAuth.HandleLoginRedirect which works great in our development environment. However, it does not work in our deployed envrionment and results in a 400: BAD REQUEST error.

Using the [http://localhost:4200/login/callback](http://localhost:4200/login/callback) works great as the RedirectURI for the dev enviroment. The sign in widget is displayed and after logging in the user is redirected back to the correct page.  
Those values have been changed in the OKTA app to reflect our production deployment values (e.g. [http://myserver.com/myserver/login/callback](http://myserver.com/myserver/login/callback)) but unfortunately in the deployed environment when we hit the “Login” button (which should direct us to the OKTA sign in widget), we get a 400: Bad Request error. All other routes that do not require OKTA sign in work in the deployed environment.

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [March 6, 2021, 10:59pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/2 "2021-03-06T22:59:53Z")

</div>

Hello,  
Could you provide the request URL/parameters causing the 400 from the address bar or dev console network tab. I also notice that the callback URL is http vs https. When you create the OktaAuth instance are you passing `disableHttpsCheck: true` as one of the parameters?

---

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 8, 2021, 5:26pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/3 "2021-03-08T17:26:58Z")

</div>

Hi Erik, I am not passing the passing `disableHttpsCheck: true `parameter through. My OKTA instance is https; although my testapp is not (thus the http in the redirect configuration).

Here is the URI being sent to OKTA for the login redirect… in development mode this brings up the OKTA login screen and then redirects back to my app correctly once credentials have been verified. However, once the app is deployed the login screen never comes up. (It is not making it that far.) I noticed others saying that once they log in they are not being redirected correctly, but for me I am not even getting the login screen to come up once deployed.

[https://dev-58568392.okta.com/oauth2/default/v1/authorize?client\_id=0oa4l9bj0ZI5hNLjP5d6&code\_challenge=Al7OBpW7AAI1XGSZUD7JW5HwMe9Ri8kD\_5lmwKOis8E&code\_challenge\_method=S256&nonce=SxvgLDlTo3AbWxrRj6LNbYI1irNWpbENC9jx73OqlEcBLMz8Z9AWihc4cfd0c5KF&redirect\_uri=http%3A%2F%2Flocalhost%2Flogin%2Fcallback&response\_type=code&state=oHgfYyzpN6acGU2IjqsCyhw9nW8GXqgIwd5Gq0ll6pPy3WALbf05AtAv187taHfx&scope=openid%20email%20profile](https://dev-58568392.okta.com/oauth2/default/v1/authorize?client_id=0oa4l9bj0ZI5hNLjP5d6&code_challenge=Al7OBpW7AAI1XGSZUD7JW5HwMe9Ri8kD_5lmwKOis8E&code_challenge_method=S256&nonce=SxvgLDlTo3AbWxrRj6LNbYI1irNWpbENC9jx73OqlEcBLMz8Z9AWihc4cfd0c5KF&redirect_uri=http%3A%2F%2Flocalhost%2Flogin%2Fcallback&response_type=code&state=oHgfYyzpN6acGU2IjqsCyhw9nW8GXqgIwd5Gq0ll6pPy3WALbf05AtAv187taHfx&scope=openid%20email%20profile)

 ![4F8EEE8048194918AC24D3939F3B29FC.png](https://global.discourse-cdn.com/oktadev/original/2X/7/7159a975d714a6caee787759490140daf4d4fda6.png)

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [March 8, 2021, 8:08pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/4 "2021-03-08T20:08:09Z")

</div>

If I click on that URL I get  
`The 'redirect_uri' parameter must be a Login redirect URI in the client app settings`  
It looks like the redirect URI is set to `http://localhost/login/callback`. Should this be set to the URL the application is being downloaded from when it is deployed, `https://myserver.com/myserver/login/callback`

The comment about others are able to login but have issues with redirecting afterwards. I am not sure what version of the Okta Angular SDK is being used, but if the application is being deployed to `https://myserver.com/myserver`, as opposed to the base `https://myserver.com`, the issue could be [this bug](https://github.com/okta/okta-angular/issues/7) which has been resolved as of 3.0.1

---

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 8, 2021, 8:47pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/5 "2021-03-08T20:47:23Z")

</div>

You are correct, that is the error I am getting. However, the redirect URI is not set to the localhost (it was during development, but I had to change that during deployment). Currently it is set to [http://IPADDRESS/myserver/login/callback](http://IPADDRESS/myserver/login/callback) (see description)

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

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [March 8, 2021, 10:18pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/6 "2021-03-08T22:18:25Z")

</div>

I do still see `http://localhost/login/callback` in the latest logs.

Even though the application is configured for a different URL in Okta I am guessing that the Angular application still has localhost somewhere in the configuration for redirectUri.

Can you check the `redirectUri` Okta config setting in the Angular app.

---

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 8, 2021, 10:38pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/7 "2021-03-08T22:38:34Z")

</div>

I have been going back and forth trying various things in order to get it to work, which might be what you are seeing? This is what the configuration in the code is currently. I have tried several different iterations to see whether I could get it to work.

![8E8AC71A8F79427E9C887748028AAF9F.png](https://global.discourse-cdn.com/oktadev/original/2X/5/5e0f63bd1def8fcea70f32282b74e21ce035a8c4.png)

I am using the following to build the application…

ng build --prod --base-href /PSOWebComm/

And when I deploy via IIS, the name of the deployment is PSOWebComm…

I have tried to hardcode the redirectUri to the following with no success:

‘localhost/PSOWebComm/login/callback’

‘IPADDRESS/PSOWebComm/login/callback’

 ![4F8EEE8048194918AC24D3939F3B29FC.png](https://global.discourse-cdn.com/oktadev/original/2X/7/7159a975d714a6caee787759490140daf4d4fda6.png)

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [March 8, 2021, 11:35pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/8 "2021-03-08T23:35:49Z")

</div>

Just to verify when you access the application after it is deployed you are using `http://ip_addr/PSOWebComm` to accces the app and not the localhost version? Which could cause this to happen.

I recommend opening a support case with support. We would like to be able to get a .har file and go over more of the configuration since SPA application deployments add extra complexity compared to traditional web apps.

---

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 8, 2021, 11:49pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/9 "2021-03-08T23:49:43Z")

</div>

Correct. [http://IPADDRESS/PSOWebComm](http://IPADDRESS/PSOWebComm)

Thank you so much for your help. I will contact support to open a ticket as I realize this is not just a straightforward issue. I will also do some further investigation on the bug and it’s subsequent workaround that you referenced previously.

Thanks again!!

 ![4F8EEE8048194918AC24D3939F3B29FC.png](https://global.discourse-cdn.com/oktadev/original/2X/7/7159a975d714a6caee787759490140daf4d4fda6.png)

---

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 19, 2021, 6:12pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/10 "2021-03-19T18:12:21Z")

</div>

Hi Erik! I opened a case in Support as you suggested, but have not been able to get anywhere as everything they have suggested does not fix the situation. I have created a simple angular app that just does a login and logout based on the documentation that I was given. The result is the same, with a small caveat. I also added the ability to Logout once I have logged in and I am having a problem with that in Development as well. Unfortunately OKTA Support says they can not help me with anything that has anything to do with code. Is this something that you might be able to help with??

Here are the details of my problem(s):

 ![4F8EEE8048194918AC24D3939F3B29FC.png](https://global.discourse-cdn.com/oktadev/original/2X/7/7159a975d714a6caee787759490140daf4d4fda6.png)

![8DEA305B2522471485377E5E040BF41A[247431].png](https://global.discourse-cdn.com/oktadev/original/2X/5/59428767a378ef4d2f34efd22ced8f3018309bea.png)

![958B7CEA1E6B48E9B972BA4B0504B6E9.png](https://global.discourse-cdn.com/oktadev/original/2X/4/474d4717c538145afe727ccb6db19abb043d2f50.png)

![0A2675FEA4814B39A7C4549192B1E14E.png](https://global.discourse-cdn.com/oktadev/original/2X/d/d455e79e3289305d52bda46ac561e6f3d6e1a492.png)

 ![B6DF0795E5924A24BF0D0D73925C06BE.png](https://global.discourse-cdn.com/oktadev/original/2X/6/6dbbb12d54a4f03e911efaf5c6759745cfdd0d37.png)

![A8CDAD94FF244221A6A8CA8766DA9CCB.png](https://global.discourse-cdn.com/oktadev/original/2X/1/18f1f52398411a9032d663a45a9a3c5a8cb9e59e.png)

---

<div class="post-metadata">

**Author:** ![heather.frazier](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@heather.frazier](https://devforum.okta.com/u/heather.frazier)\
**Post date:** [March 19, 2021, 6:54pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/11 "2021-03-19T18:54:20Z")

</div>

Please disregard the “Logout” error. I was able to resolve that by only including the machinename/port for this in development which works. The “Login” issue during deployment still holds true.

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

 ![4F8EEE8048194918AC24D3939F3B29FC.png](https://global.discourse-cdn.com/oktadev/original/2X/7/7159a975d714a6caee787759490140daf4d4fda6.png)

![958B7CEA1E6B48E9B972BA4B0504B6E9.png](https://global.discourse-cdn.com/oktadev/original/2X/4/474d4717c538145afe727ccb6db19abb043d2f50.png)

![0A2675FEA4814B39A7C4549192B1E14E.png](https://global.discourse-cdn.com/oktadev/original/2X/d/d455e79e3289305d52bda46ac561e6f3d6e1a492.png)

 ![B6DF0795E5924A24BF0D0D73925C06BE.png](https://global.discourse-cdn.com/oktadev/original/2X/6/6dbbb12d54a4f03e911efaf5c6759745cfdd0d37.png)

![A8CDAD94FF244221A6A8CA8766DA9CCB.png](https://global.discourse-cdn.com/oktadev/original/2X/1/18f1f52398411a9032d663a45a9a3c5a8cb9e59e.png)

![8DEA305B2522471485377E5E040BF41A[247431].png](https://global.discourse-cdn.com/oktadev/original/2X/5/59428767a378ef4d2f34efd22ced8f3018309bea.png)

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [March 21, 2021, 11:31pm UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/12 "2021-03-21T23:31:09Z")

</div>

Hi Heather,  
I recommend to try to change the login redirect uri within Okta to `https://psodemo/PSOWebComm/login/callback`

Note the change is the hostname to all lowercase. Assuming your code is still using window.location.origin I am guessing the hostname will be all lowercase. Okta will do a direct string comparison.

If you still see the same issue verify that in the dev console network tab of the browser that when the /authorize call happens that the redirect uri sent to Okta exactly matches what is set in the Okta application.

One last thought, if you have more then one application in Okta, verify that when you change between the two the correct client\_id in the source code is updated.

Hopefully one of those will work!

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [January 27, 2024, 12:01am UTC](https://devforum.okta.com/t/redirecturi-causes-error-in-angular-deployment/13196/13 "2024-01-27T00:01:25Z")

</div>

Closed on January 27, 2024, 12:01am UTC


