最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Domain Attribute Invalid - Set Cookies - Stack Overflow

programmeradmin0浏览0评论

I have built a basic demo backend using nodejs and ui using reactjs. When I login in using credentials, I am trying to set cookies. But it says some things like this "this. set-cookie domain attribute was invalid with regards to the current host URL". I have deployed both backend and ui on to Heroku separately. All network request is working fine. But the only issue I am facing is set-cookies not getting updated says domain attribute was invalid. Can anyone please guide me or suggest me where I am going wrong

Ui Doamin URL - /

Node end point what i configured is something mentioned below

 return res.
 cookie("auth",token,{domain: "visitplanui.herokuapp",path: "/"}).status(200).
 send ({code:  200,status: "Account details found & authenticated",})

I have built a basic demo backend using nodejs and ui using reactjs. When I login in using credentials, I am trying to set cookies. But it says some things like this "this. set-cookie domain attribute was invalid with regards to the current host URL". I have deployed both backend and ui on to Heroku separately. All network request is working fine. But the only issue I am facing is set-cookies not getting updated says domain attribute was invalid. Can anyone please guide me or suggest me where I am going wrong

Ui Doamin URL - https://visitplanui.herokuapp./

Node end point what i configured is something mentioned below

 return res.
 cookie("auth",token,{domain: "visitplanui.herokuapp.",path: "/"}).status(200).
 send ({code:  200,status: "Account details found & authenticated",})

FYI please find the below screenshots

.

Share Improve this question asked Dec 18, 2019 at 18:03 Nagendra NNagendra N 1821 gold badge2 silver badges7 bronze badges 1
  • Hey @nagendra-n, were you able to solve your problem? If yes, could you please share your solution? – michcio1234 Commented Mar 20, 2020 at 10:22
Add a ment  | 

2 Answers 2

Reset to default 4

Heroku does not allow the installation of third-party cookies in its domain [application name] .herokuapp. in accordance with the server’s response. Only if you set cookies via js can you change them. To set third-party cookies, you need to add your own domain, which you can purchase through any domain registration service. Pay attantion while registration nw domain, pany that maintains the DNS servers that translate a custom domain name to a destination ('DNS Target’). The fields are often called CNAME, ALIAS, ANAME, or A records. Only the first three work with Heroku apps, as A records require an IP address and Heroku apps do not have stable inbound IP addresses.

Alexandr's answer seems to be on point. You cannot set cookies on herokuapp. due to reasons mentioned here

So the best option is to buy a domain and then try to set it there. Check out the link for better understanding.

发布评论

评论列表(0)

  1. 暂无评论