Website comes up as soon as I start typing - node.js

I have an application in Node/Express that is exhibiting some strange (to me, at least) behavior. I am not sure why this happens, but as soon as I begin typing in the URL, the web page instantly comes up. All the logs start populating data and I have my home screen. This is on a local instance for now as I'm still trying to work out bugs related here. I believe these two may be inter-related, but I can't find any data online; perhaps I'm using the wrong search terms, but the long and the short of it is this:
I'm connected to a VM (CentOS7) and everything is run through AWS. I type in my IP:PORT (e.g. 12.34.56.78:9999). As SOON as I type the '1' in the URL, all the logs fire, running through all the scripts. Since I'm at my home page, I hit 'Enter' and is SUPPOSED to go through a redirect to an authorization page (e.g. 12.34.56.78:9999/auth). At that point we're running into my original post, identified above, but this question is simply an attempt to understand why my web page is being shown before I ever 'finish' the call by hitting the 'Enter' key. Is this normal behavior when an application is being accessed locally?

Because your browser is "smart" and guesses that you want to open that website and will therefore load it before you complete the url. That of course only happens if you have previously visited that site, otherwise the browser does not know the url yet. What logic the browser internally uses for this decision depends mostly on the browser and its settings, wether it factors in how recently you visited it or how often, or ...
If you actually want to browse that website when you finish typing the browser has already loaded the page and can instantly display it instead of now loading it and letting you wait a couple of seconds. If you decide you want to go to 123.com instead the browser simply discards the preloaded page and continues as normal.

Related

Url loaded between every resource. JSF, OracleWebServer

At random (1 out of 100 maybe) the login page to a web application seems to not load any resources, including the CSS. When I was finally able to recreate this issue with network traffic monitored I found some very strange behavior. First, the html page contents get loaded after each resource fetch (see pic 1). Second, all the resource fetches have completely empty response bodies (not shown). Third when I click submit, the normal POST action by j_security_check gets run, but it doesn't seem to do anything and one of the javascript files that is supposed to be fetched and run at the beginning of the page load attemps to be saved to the computer instead. The javascript file is fetched near the bottom, called autocomplete.js.jsf. The contents of autocomplete.js.jsf is a simple framebuster security check:
/**
* Prevent FrameBuster attack
*/
if (window.top.location !== window.location) {
window.top.location.href = document.location.href;
}
Below is an attached picture of the login page and the network traffic. Sorry for all the black, but I am basically a contractor and want to avoid any clues of the client if I can.
Below is what the login page is supposed to look like, with normal web traffic.
Project Info:
I am working on Icefaces v3.3 running on a weblogic v12 server.
I have no idea why this is happening. If anybody could shed some light on why the network traffic looks the way it does, and why it affects the page the way it does I would be very grateful.

Node/Express app find onhashchange event handler

I'm working on a Node.js website, I've taken the work on for a charity and I confess I'm learning on the job.
The page in question starts with content rendered, but invisible. When you click a button that redirects to a URL starting with a # ( which means it gets appended to the page ), no get occurs, but the content is revealed . The issue is, it needs to be filtered. However, I cannot figure out what is triggering this. The word 'hashchange' does not occur in the code base. The window.onhashchange event is null. Where would I look to try to track down the code that is doing this ?
The content after the hash mark is called an URL fragment. URL fragments are not sent to the server and appending an URL fragment does not typically invoke a page fetch, so it makes sense that no get occurs.
URL fragments are commonly used to keep track of navigation state on the browser side. This is common with single page apps (SPA) that will only fetch the entire page from the server once, and handle the rest of navigation using javascript, pushState, and AJAX queries.
This is presumably what is happening when you navigate to different tabs. The client side javascript is appending URL fragment in order to push state onto the browser history without forcing an unnecessary page reload. Note that this code does not need to listen to the onhashchange event in order for this to work, which is why you don't see any mention of it in your code search.

Chrome connects websocket just by pasting URL into navbar

I recently noticed something with Chrome and Websockets (particularly with node/socket.io) where the browser will connect my socket when I paste the URL to my page into the URL bar (without actually going through with the page request). I can verify this by simply consoling out "Connected!" and "Disconnected" in their respective socket events.
Now, I've read that Chrome has the ability to preload some parts of webpages when they are typed into the URL bar, and I would imagine that this is what is happening, however, the second part to this issue is that when I remove the url from the bar, it does not disconnect. Furthermore, if I even go to another page in that same tab, still no disconnect.
Also, it seems if I re-paste the url into the bar, the server disconnects and then reconnects.
I feel this could be a major hassle with some implementations of sockets (at least mine). Does anyone have more information about this or a way around it? Am I using the wrong events?
Chrome version: 34.0.1847.131

Web design/development - alternative to manually refreshing the page?

I wonder if there is a better way to write my PHP sites without always having to manually refresh the page I'm working on. Could there be a program that monitors a folder and automatically refresh my browser whenever a change occurs. I'm developing on a local machine with a local amp stack by the way.
You can achieve this by ajax. In ajax you can check the changes in database if any new record added you can call
location.replace('');
in ajax success
Use Ajax poll (checking for status change on server with time intervals) and when the change occurs, either refresh the page with Javascript or replace the part of it to reflect the change.

How to edit a web interface (front end)

I want to make some changes to the Octoprint 3d printing web interface in order to fit my expectations. In order to change values and observe the results, I apparently have to recompile every time even if the changes are on the front end and not in the back end. Is there a way to observe the changes to the front end without recompiling?
Yes, there is. The changes in front-end are contained in browser and are not dependent on server. Any changes to front-end code is immediately available to browser, and can be seen by a debugging tool - like firebug in firefox, or firebug lite.
You have to reload page on browser to load new changes in front-end code.

Resources