I have a client component which is a modal for login. i need to send the data to the backend server via a post request very simply what I’ve done so far is like below:
const [mobileNumber, setMobileNumber] = useState("");
const onLogin = useCallback(async () => {
await axios.post(
"https://******.com/Authenticate",
{ mobileNumber, fullName: "" },
{
headers: {
"Content-Type": "application/json",
},
withCredentials: false,
}
);
}, [mobileNumber]);
I already saw other answers about this issue which was changing the middleware file or directly set the headers inside the next.config file but i don’t use api directory (to be honest i didn’t underestand it so far why i should use that) and also i don’t have any middleware file. is there a way i can fix this error?
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://******.com/Authenticate. (Reason: CORS request did not succeed). Status code: (null).
btw the normal GET request is working fine but I don’t understand why this post request is not working.