I am creating a front end in AngularJS for a backend in node.js. I have the option of two simple node.js front end servers to serve the front end web page: one is a simple app.get in express, the other is using the http-server package.
Whichever front end server code I use, I get the following browser console message in Chrome:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
To make sure that this was not caused by anything Angular (or Bootstrap) I have cut back my webpage to the following:
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>zoneshark</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
Why am I getting the error message? Does http-server always cause this error? How can I set up a front end server using nodejs so that this error does not occur (just this simple "hello world" page would be a starting point)?
The server code I am using as an alternative to http-server is:
var express = require('express');
var app = express();
app.get('/', function(req,res) {
res.sendFile('./index.html', {root: __dirname});
});
app.get(/^(.+)$/, function(req, res) {
res.sendFile('./' + req.params[0], {root: __dirname});
});
app.listen(80);
Another oddity. From the http-server console, it looks like http-server is serving two resources: /index.html as expected, but also /favicon.ico - which is odd as this is not mentioned anywhere.
The final oddity: this only happens from Chrome. From IE there is no issue, and no favicon.ico is called for.
In Chrome, I have cleared all browsing data, except autofill form data, passwords and content licences.
async
in the MDN docs – Define