4

Hi I've been stuck on this for days! I'm trying to use keycloak to authenticate my electron app after converting my react app using this guide.

When I run 'npm run electron:dev' , keycloak redirects to the login page. However, when I run 'npm run electron:prod' this fails.

Logs from keycloak server shows:

Server:server-one] 08:58:31,575 WARN  [org.keycloak.events] (default task-3) type=LOGIN_ERROR, realmId=codingpedia, clientId=my-ui, userId=null, ipAddress=127.0.0.1, error=invalid_redirect_uri, redirect_uri=file:///home/mycompany/john/projects/boilerplate-javascript-electron/app/build/index.html

Notice that the redirect_uri is 'file:///...' which I believe to be the cause of it.

I've also tried to change the below but it does not resolve the problem.

// import createHistory from 'history/createBrowserHistory';
import createHistory from 'history/createHashHistory';

Why is this working in dev but not in prod? Is there something I'm missing? Thank you in advance!

johnwick0831
  • 918
  • 1
  • 12
  • 24

1 Answers1

0

It works in dev probably because the "index.html" file is located in your computer (file:///home/mycompany/john/projects/boilerplate-javascript-electron/app/build/index.html).

This stackoverflow thread tells how to properly set the redirect_uri parameter, through the admin console.

Note: make sure you can remotely access your index.html in prod, using a browser or any other client tool (HTTP GET).

Fabio Manzano
  • 2,847
  • 1
  • 11
  • 23