How to retrieve Information from Java Spring backend to use on React frontend?

I have a backend server which uses Java SpringBoot, running on port 8080 and a frontend server which uses React, running on port 3000.

I want to be able to authenticate a user’s login on the frontend by what I think would be a GET request through axios.get() to the backend through querying the MySQL database and see if the user exists in the results (returned from doing a simple select * from users) . There might be a better way.

Initially I have researched how some articles show the connection to the database and data querying being performed on the frontend e.g. https://javascript.plainenglish.io/build-a-simple-login-system-with-react-and-mysql-7b491737abac ) but that doesn’t seem secure and would slow things down.

Any thoughts?