Q: Setting Cookies does not work in production Vuejs, vuecookies Im using Vue.js 3 & the vue-cookies package  Vue Cookies
this is how im setting the cookies in the app
in main.js
import VueCookies from "vue-cookies";
app.use(VueCookies, { expires: "35min" });

in login.vue
const $cookies = inject("$cookies");

const handleLogin = async () => {

try{
const res = await axios({
            method: "POST",
            url: "/sellers/login",
            data: {
                Email: email.value,
                Password: password.value,
            },
            // withCredentials: true,
        });

       let token = res.data.token;
        // $cookies.set("jwt", token);  //---->method 1

        const storeToken = useLocalStorage("token", {
            token: res.data.token,
        });
        await new Promise((resolve) => {
            setTimeout(resolve, 3000);
        });
        let storedToken = JSON.parse(window.localStorage.getItem("token"));

        $cookies.set("jwt", storedToken.token);  ///---> method 2

        console.log("getting the cookie");
        let y = $cookies.get("jwt");
        console.log(y);
}

catch(error){
}

i've tried storing the cookie in local storage then retrieving and setting it from there (method 2) because i thought the problem was method 1
the results of console.log(y) is null
however,i have confirmed the token is in local storage
Both Method 1 & 2 work when the app is running via the Vite development server
After building for production and serving the assets in dist with nodejs, it does not work
what im i doing wrong or haven't done?
i can see the response from the node.js server and even save them in localstorage (like the token)
i can also retrieve the token from localstorage
setting the token from localstorage (method 2) or setting it direct from the response (method 1) is what is not happening
i appreciate your help

A: First of all, you shouldn't create authentication cookies or save any kind of authorization token this way. It makes a good vulnerability for XSS attacks. You should try to set the cookie from your backend with the httpOnly attribute which is not possible from the client side.
Regarding your problem, it's quite difficult to say what could be the problem on production. My best guess is that your production environment is using https and your cookie is being set insecurely by the package you are using as its the default. Therefor, it is only accessible when using http which you are probably using for development.
Try to set the config to use secure cookies when your import.meta.env.PROD equals true like this example below:
$cookies.config('35m', '', '', import.meta.env.PROD)

You should also make sure that the correct domain is set so it's accessible from the client.
