Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain Attribute Invalid - Set Cookies

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.com/

Node end point what i configured is something mentioned below

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

FYI please find the below screenshots

.enter image description here

enter image description here

enter image description here

enter image description here

like image 780
Nagendra N Avatar asked Dec 18 '19 18:12

Nagendra N


People also ask

What is domain in set cookie?

Set a cookie domain The domain can be used to specify a subdomain for your cookie. document. cookie = 'name=Flavio; domain=mysite.com;' If not set, it defaults to the host portion even if using a subdomain (if on subdomain.mydomain.com, by default it's set to mydomain.com). Domain cookies are included in subdomains.

Can you set cookies for another domain?

You cannot set cookies for another domain. Allowing this would present an enormous security flaw.


1 Answers

Heroku does not allow the installation of third-party cookies in its domain [application name] .herokuapp.com 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, company 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.

like image 98
Alexandr Avatar answered Sep 28 '22 18:09

Alexandr