firefoxview-source

Firefox VIEW SOURCE shows login page


I'm running Firefox 61.0 on Arch Linux. When viewing the source of a page, I frequently (but not always, estimated 20% of the time) see the source code of the login page when I'm browsing a website that requires me to log in. This happens when I'm browsing localhost. The source code of each page is generated on the server, this is not a problem with the DOM being manipulated. It happens using Django as well as PHP. Example:

LOGIN PAGE:

<html>
<title>Login</title>
<body>
Login please: [    ]
</body>
</html>

HOME PAGE:

<html>
<title>Welcome USER NAME</title>
<body>
Good day, USER
</body>
</html>

After I have logged in and I am on the homepage, I hit CTRL+U, it will show me:

<html>
<title>Login</title>
<body>
You are logged in as USER
</body>
</html>

In other words, it isn't taking the previous page from its cache; it seems to somehow try and fetch the source code of the page I'm on but it is redirected to the login page.

NOTE: if I run INSPECT ELEMENT on the page then I do see the right source code. The problem is only with VIEW SOURCE. This does NOT happen in Chrome or other browsers, just in Firefox.

Any idea why this could happen?

To clarify: these are two different pages. The login page is login.php and the home page is index.php. When I CTRL+U on index.php, Firefox shows me the source code of login.php, even though I am already logged in.


Solution

  • Apparently, this has always been an issue with Firefox's "view source". Here's a bug that was reported 13 years ago describing the process by which Firefox loads the page's source code by refreshing/re-requesting the whole page.

    It is possible that an uncached version of the page is being downloaded, and thus, showing different results for the debugger and the source. It all depend's on how the login data is being handled (cookies, session variables, server variables, etc.)

    Here's another Steckoverflow question on a related topic. I hope this can give you an idea on how to solve the issue you're having.