DEV Community

Ashish R Bhandari
Ashish R Bhandari

Posted on • Edited on

Error due to (.) in Domain Name End[www.ashish.com.]

1) I saw a Very Interesting behavior today.
Let me explain it with an example

https://www.google.com./
https://www.google.com/

Both URL are ALMOST Same the difference is a (.)

The Above Both URL will access the same Resource, Also If we do the DNS LOOKUP, we will GET the same IP [Yes it will change depending on DNS and it's config] [To Check it Please Use a Domain that Points to only one IP]

A Quick Look [example.com]

C:\Users\@sh>nslookup example.com
Server:  dns.google
Address:  8.8.8.8

Non-authoritative answer:
Name:    example.com
Addresses:  2606:2800:220:1:248:1893:25c8:1946
          93.184.216.34


C:\Users\@ash>nslookup example.com.
Server:  dns.google
Address:  8.8.8.8

Non-authoritative answer:
Name:    example.com
Addresses:  2606:2800:220:1:248:1893:25c8:1946
          93.184.216.34
Enter fullscreen mode Exit fullscreen mode

So The Main Point to Focus, is yes a "." at End is accepted in DNS Query and So in Chrome or FireFox Browser.

The Same Happens When the Browser tries to access such a URL.

The Results were Hilarious.

The Browser will Treat Both as 2 Different Domains [As per what i understood from it].
Which means that if i Go to https://www.google.com./
Then Browser will not send any Cookie that is for "Google.com" or "www.google.com"
[i.e Any Cookie Set for google.com and it's subdomain]

ALSO

Browser will not send any Cookie when the Request is made to google.com and it's subdomain via a "www.google.com." [ending with a DOT(.)]
IF the Cookie SameSite Attribute is Not None.
Because it will treat it as a CSR [Cross Site Request]
and only Cookies with SameSite Attribute as None are sent by the Browser

[Also if the Request is not a Top-Level Navigation, In Other words if the Link Accessed does not Show in Browser's URL Bar Cookies will not be Sent]

Which Means if you are logged in to Google and then on the URL Bar you access

This is the Result I Got

Google.com with . at End

Let's do some Debugging

The Browser Says that it cannot set the New Cookie Received From "www.google.com." which is "www.google.com", but the Browser will match it with "www.google.com." [Since this is what was requested by the user and this is what is shown in the Browser URL Bar]

Therefore, No Cookie which was for "www.google.com" was sent and the Received Cookies were also discarded as the domain or the URL Path (Hard to tell what!!) did not qualify for "www.google.com." [With a (.)]

Browser Rejects Sending Cookies and Receiving Cookies!

I am Already Logged in Therefore when I click on sign in

Google in "www.google.com" is Proper

Note:
Please Feel Free to Comment your own View points and correct me

Top comments (2)

Collapse
 
ricobrase profile image
Rico Brase

That's just how DNS works. The trailing dot means that the hostname is an absolute path and not relative to your current local domain.

If your local network is called "example.local", you could setup a local DNS server in your network, to resolve "google.com" to a device in your local network.

Entering "google.com" in your browser will then be the same as entering "google.com.example.local" and you won't be able to access Google anymore.
That's basicly the same as having a computer with the hostname "my-computer" in your network - you can access a running webserver by typing in "my-computer" into your webbrowser, effectively navigating to "my-computer.example.local".

Adding the trailing dot to the URL as in "google.com." tells the DNS server, that you didn't left out the "example.local" due to laziness, but because you want, in fact, navigate to "google.com" and not to "google.com.example.local".

You can think of it as relative and absolute paths on your computer.
On a Unix-based operating system, a file path starting with a slash will be an absolute path, while paths without a leading slash will be treated as relative to your current working directory.

Summary:
google.com --> relative to your current domain
google.com. --> absolute to the top-level domain

Collapse
 
aashishrbhandari profile image
Ashish R Bhandari

This is a Great Knowledge Rico Brase that you have shared.
I really liked the Explanation of "google.com" and "google.com."
I am Going to try this.
Thanks alot.
Can you help me with my other Posts as well.
Providing your knowledge on those will help me Explorer more.