I try to use angular-oauth2-oidc with google social network and work on development and production. I use nest.js part as the backend. I use docker to build nest.js and angular parts and copy all needed files into ‘public’ folder. The problem is that it works in the different way for development and production.
So, user presses a button and code is executing:
this.oAuthService.configure(googleAuthConfig);
this.oAuthService.loadDiscoveryDocumentAndTryLogin();
this.oAuthService.initLoginFlow();
…
export const googleAuthConfig: AuthConfig = {
issuer: 'https://accounts.google.com',
clientId: MY_CLIENT_ID,
scope: 'openid profile email',
clearHashAfterLogin: false,
strictDiscoveryDocumentValidation: false,
redirectUri: google_environment.redirectUri,
};
and google_environment.redirectUri is different for development
export const google_environment = {
production: false,
redirectUri: 'http://localhost:4200/authorization-checking',
};
and production
export const google_environment = {
production: true,
redirectUri: 'https://my-some-application-pqyo.onrender.com/authorization-checking',
};
and I set up the same redirect URIs on the google side
I also have route in the app-routing.module on the angular side:
const routes: Routes = [
{ path: 'authorization-checking', component: AuthorizationCheckingComponent },
...
While developing it works. As far as I understand in this case webpack-dev-server intercepts redirecting from google and passes it through angular path.
But in the case of production situation is different and redirect goes to the route processing on nest.js and angular handler does not work
How can I configure redirection to work uniformly in development and production using Angular, Nest.js?