So I'm using Node/Express for my backend and React for frontend. I'm building a simple authentication system myself using JWT, and storing it into httponly cookies, and sending it to the frontend. All is going well for in development where I use localhost:5000 and localhost:3000 for my server and client addresses respectively. My httponly cookies are properly set and I can see them in my console.
However, only when I deploy it to my website, suddenly, the cookies are not set. Everything else works fine though. I made sure my addresses are all changed to the website.
Backend code:
const server = express();
server.use(cors({origin: "https://frontendwebsitename.com", credentials: true}));
server.use(express.json());
server.use(express.urlencoded({extended:true}))
server.use(cookieParser())
Frontend API code:
axios.defaults.withCredentials = true
export const loginAuth = async (credentials) => {
return await axios.post("http://backendwebsitename/loginAuth", credentials).then((res) => {
return res
})
}