How to throw exception from Spring Boot backend direct to React frontend?

I want to know the best way to throw exception from the backend direct to frontend directly. In my case I have create an endpoint that control SSO login with google and I need to make a validation for the email address that need to be in a specific domain. On the case the email invalid with domain so, I want to show the error message that email that have used is invalid on the React frontend. Please help me because I need to complete this case very urgent.

Hello @Keat,
There is a very good guide about Authentication with Spring Security in the docs: Authentication with Spring Security | Security | Guides | React | Hilla Docs. It uses the LoginOverlay component and shows how to display authentication errors using this component.