When your backend is deployed to aws and you have to develop http cookie authentication to a locally hosted reactjs frontend how do you implement it?
The issue is..
When I call the login API endpoint it's supposed to set a http-only cookie to my browser but it doesn't.
I've mentioned my axios intecepter below incase if it's the issue. If you can suggest me a solution that would be great.
ps : the backend doesn't have a issue, When i call the login endpoint with postman. relevant cookies are setting automatically
export const axiosHttp = axios.create({
headers: { "Content-Type": "application/json" },
withCredentials: true,
});
axiosHttp.interceptors.response.use(
(response) => response,
async (error) => {
const prevRequest = error?.config;
if (error.response.status === 401 && !prevRequest?.sent) {
prevRequest.sent = true;
const res = await refreshToken();
console.log(res);
return axiosHttp(prevRequest);
}
return Promise.reject(error);
}
);