Answer the question
In order to leave comments, you need to log in
Why do I see a cookie in the response from the server but not in the storage?
Hello! devServer at :3000, Express at :8080, I'm trying to put a cookie in the response from the server.
Backing code:
app.use(cors({
origin: "http://localhost:3000"
}));
Router.route("/login").post((req, res) => {
UserSchema.findOne({login:req.body.login}).then(user => {
if (user === null) {
UserSchema.create(req.body).then((data) => {
res.cookie("userID" , data._id, { HttpOnly: true}).send(data);
});
}
else {
if (user.password === req.body.password) {
res.cookie("userID" , user._id, { maxAge: 900000, httpOnly: true}).send(user)
} else {
res.send({error: {message: "Wrong password"}})
}
}
})
});
const axiosInstance = axios.create({
baseURL: process.env.BASE_URL,
headers: {
'Access-Control-Allow-Origin': '*',
}
});
Answer the question
In order to leave comments, you need to log in
Because the code needs to be copied wisely...
res.cookie("userID" , data._id, { HttpOnly: true} )
PS Access-Control-Allow-Origin is a server header, it makes no sense to send it from the client
Replace
on the
<?php
$curPage = $APPLICATION->GetCurPage(true);
if (
$curPage == SITE_DIR."index.php"
){?>
<div class="logo-up"><img src="<?=SITE_TEMPLATE_PATH?>/images/logo-up.png" alt="" /></div>
<?}else{?>
<div class="logo-up"><a href="<?=SITE_DIR?>"><img src="<?=SITE_TEMPLATE_PATH?>/images/logo-up.png" alt="" /></a></div>
<?}?>
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if(SITE_DIR == $actual_link) {
return true; //Если главная
} else {
return false; //Если не главная
}
In the right CMS, the body or page IDs change depending on what page is currently displayed. Based on this, you can truncate the output of your a href site_dir.
If the CMS is wrong, then only "scams"...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question