You can return this
return {
redirect: {
permanent: false,
destination: "/login",
},
props:{},
};
instead of setting header.
That error arrived due to two responses sent by the serversideprops. One in the return and one by header.
You can read more about redirect here