I have nginx proxypass configured mapping https://newcompany.com/subdir to http://someserver/login
I have access to vm corresponding to someserver. Am copying contents of build directory of my react app to apache2 at var/www/html directory of someserver.
Client information
I have specified following in react:
<Router basename="subdir">
following in package.json:
"homepage": "/subdir",
and following in my .env.staging:
PUBLIC_URL=https://newcompany.com/subdir
Server configuraiton
I am running spring boot server running at someserver's port 8080. It has following configurations:
.logout(l -> l.logoutSuccessUrl("http://newcompany/subdir/login").permitAll())ref.oauth2Login().defaultSuccessUrl("http://newcompany/subdir/dashboard")ref , ref
Behavior
When I hit https://newcompany.com/subdir/login I get correct page. It has "Login with Google" button. But after successful login it redirects to https://newcompany.com/subdir/login page instead of https://newcompany.com/subdir/dashboard. If I hit https://newcompany.com/subdir/dashboard, it redirects to https://newcompany.com/subdir/login. Now if I try to hit http://someserver/subdir/dashboard, it shows me logged in user and I can access the whole website. But why it is not getting redirected to https://newcompany.com/subdir/dashboard after successful login? what could be the reasons?
PS:
I checked the network traffic also.
- After successful login google oauth redirects to
http://someserver:8080/login/oauth2/code/googlewith authorizationcode=in is url params - Then
http://someserver:8080/login/oauth2/code/googleredirects tohttp://newcompany.com/subdir/dashboardwith cookieJSESSIONID - Then
http://newcompany.com/subdir/dashboardredirects to itself twice with sameJSESSIONID
Note that after google login, I could not see http://someserver:8080/login/oauth2/code/google and http://newcompany.com/subdir/dashboard in the browser address bar. So after oauth login I get to see directly https://newcompany.com/subdir/login in the browser address bar. Also notice that https://newcompany.com/subdir/login never appears in the network traffic.