Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JHipster Social Login Google Authentication error Cannot POST /signin/google

Created an application from https://start.jhipster.tech/#/generate-application with JWT and Enabling Social Login, From Google generated the clientID, clientSecret and update the application.yml .

In google console's Client ID for Web application, Authorized JavaScript origins are specified as http://localhost:8080 and http://localhost:9000

The "Authorized redirect URIs" are set as http://localhost:8080/signin/google and http://localhost:9000/signin/google

After yarn install , yarn start and .mvnw ( spring-boot:run ), the application can be run at http://localhost:8080 and http://localhost:9000

Login with google works fine when application is accessed from http://localhost:8080 , when accessed from http://localhost:9000, the social login page says Cannot POST /signin/google and url of the browser change to http://localhost:9000/signin/google

like image 671
Raj Avatar asked Nov 07 '22 13:11

Raj


1 Answers

By default, the url for the spring social is not defined into the jhipster webpack configuration.

You should modify the file webpack/webpack.dev.js to add the /signin path to the dev server configuration as follows :

devServer: { contentBase: './target/www', proxy: [{ context: [ /* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */ '/api', '/management', '/swagger-resources', '/v2/api-docs', '/h2-console', '/auth', '/signin' ], target: 'http://127.0.0.1:8080', secure: false }], watchOptions: { ignored: /node_modules/ } }

And in the google api credentials, you should add in the redirect urls: http://localhost:9060/signin/google

like image 53
F. Geraerts Avatar answered Nov 30 '22 12:11

F. Geraerts