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 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/)
What can be wrong?
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.
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'));
});
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
Here are my app settings
Here my CORS settings
In oidc I changed redirectUri from âhttp://localhost:4200/implicit/callbackâ to âhttps://your-favorite-places.ew.r.appspot.com:8081/implicit/callbackâ.
Here is a test account for your help:
login: stipe_miocic@test.com
pass: 123456789Nn
Could anybody help me?
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.
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.
Thank you very much! It works!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.