I have following method for the login in the Controller. The problem is when our front end developer try to login from the web-browser for the login he get this error in the front end side:
Access to XMLHttpRequest at 'http://ip-adress:port/login' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
LoginPage.js:35 Error: Network Error
at createError (createError.js:16:1)
at XMLHttpRequest.handleError (xhr.js:117:1)
xhr.js:210 POST http://ip-adress:port/login net::ERR_FAILED 403
I founded this following solution and add in my spring boot application of configuration class.
and:
We no longer get the cors origin error. But This time I am getting the following warning in my spring boot project. When front end side try to login.
01-2022-12 [warn ] org.springframework.web.servlet.handler.abstracthandlerexceptionresolver.logexception(abstracthandlerexceptionresolver.java:207) - resolved [org.springframework.http.converter.httpmessagenotreadableexception: required request body is missing: public org.springframework.http.responseentity<com.company.ldap.resource.responseresource> com.company.ldap.controller.domainlogincontroller.login(com.company.ldap.data.dto.domainloginrequestdto)]
and front end side this error occur.
Error: Request failed with status code 400
at createError (createError.js:16:1)
at settle (settle.js:17:1)
at XMLHttpRequest.onloadend (xhr.js:66:1)
POST http://172.16.8.84:7070/login 400
This is my controller clas:
but when I try to make the post request from the postman for the login I didn't get in the above error, everything work fine.
This is my RequestDto class:
I searched a lot of things but couldn't find a solution. Can you tell me something about what to do?