i can’t see my cookie with the dev tool and don’t understand if its because my cookie is poorly set up or it is because it is set up but at a place I can’t see
i try using the mehtode of res.setHeader but I didnt work either so I run out of option know fore me
const express = require("express");
const cookieParser = require("cookie-parser");
const path = require("path");
const { createClient } = require("@supabase/supabase-js");
const { createServer } = require("node:http");
const { join } = require("node:path");
const { Server } = require("socket.io");
var cors = require("cors");
const { error } = require("console");
const app = express();
const server = createServer(app);
const io = new Server(server);
const supabaseUrl = "myurl";
const supabaseKey = "mykey";
const supabase = createClient(supabaseUrl, supabaseKey);
const port = process.env.PORT || 5000;
const corsOptions = {
origin: "http://localhost:3000",
optionsSuccessStatus: 200,
};
app.use(cookieParser());
app.use(cors(corsOptions));
app.use(express.json());
async function authenticate(userIdFromCookie) {
console.log("appelle de la fonciton authenticate");
if (userIdFromCookie !== undefined) {
console.log("User ID found in cookie:", userIdFromCookie);
return true;
} else {
return false;
}
}
app.post("/chat", async function (req, res) {
try {
const userId = req.body.userId;
const isAuthenticated = await authenticate(userId);
if (!isAuthenticated) {
const { data, error } = await supabase.from("post").select();
if (error) {
return res.status(500).json({
error: `Error fetching data from Supabase`,
});
}
res.cookie("userId", 3);
console.log("cookie setup");
return res.json(data);
} else {
return res
.status(500)
.json({ error: "activer les cookies ou recharger la page svp" });
}
} catch (err) {
console.error(err);
res.status(500).json({ error: "Internal Server Error" });
}
});