Is it possible to set an HttpOnly Cookie from one domain to another subdomain
Solution 1:
This is possible. In fact I just did it.
On your frontend, using Axios:
const baseURL = "https://api.example.com";
const api = axios.create({
baseURL,
withCredentials: true,
});
On your backend, using Express:
app.use(
cors({
origin: "https://www.example.com",
credentials: true,
})
);
app.post("/login", async (req, res) => {
res.cookie("someCookie", someCookieValue, {
secure: true,
domain: "example.com",
httpOnly: true,
});
})