React + Express + Login redirection

I’ve implemented Okta login successfully on ReactJS, managed to login with user information retrieved. However when I npm run build my project and host them together with my Express. After okta login, the application complains about

Cannot GET /login/callback

I believe this is due happening due the routing set within Express JS? Can someone shed some light on this?

FYR the express code

app.set("views", path.join(__dirname, "./build"));
app.engine("html", require("ejs").renderFile);
    express.static(path.join(__dirname, "./build/static"))


I have modified my express code to the following

// Serve the static files from the React app
app.use(express.static(path.join(__dirname, ‘./build’)));
// Handles any requests that don’t match the ones above
app.get(‘*’, (req,res) =>{
console.log(‘unrecognized files’)

So right now all the unrecognized path, is actually going to open index.html. And unfortunately my login/callback is also falling under this path.

@andrea can you help to comment on this? Thanks :pray:

Finally managed to resolve this issue, I have posted the resolution here in this Stackoverflow post.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.