npm http-server downloads index.html instead of serving - html

I am using http-server with ssl certificate in order to test facebook instant games. However, while server is running localhost makes my browser download index.html file instead of actually serving it in a browser. The problem occures in chrome, but microsoft edge seems to be fine.

Use this URL http://127.0.0.1:8080/
instead of localhost:8080

I found out this problem only occurs in Chrome, edge seemed to work fine, so I decided to clear browsing data in the chrome settings and tried again and surprisingly it doesn't download index.html from localhost:8080 anymore! This method solved my issue.

Related

github pages site doesn't work in some browsers

I made github pages site with a custom domain.
It runs in Tor and Safari but I get "This site can’t be reached" message trying to run it in Chrome and some other browsers, what could be wrong?
The repository is public, cache is cleaned.
There was a problem in C:\Windows\System32\drivers\etc\hosts file where my domain name was pointed to localhost
the file was changed probably probably due to my attempts to host the site on a laptop

Chrome returns ERR_FAILED for localhost

After some experiments with PWA I've encountered a strange issue with Google Chrome only. Every other browser works just fine.
When I load http://localhost the response is: "This site can’t be reached"
The error status is: "ERR_FAILED" (404)
Note:
"ping localhost" returns 127.0.0.1 (as it should be).
wget -qO - 'http://localhost' loads the correct content in terminal.
every other browser loads the correct content.
the setting in /etc/hosts leads to 127.0.0.1
if I access the content via IP (127.0.0.1) it loads just fine.
I have cleared the browsing cache
the PWA cache seems to be clean.
The offline box in the network tab is not checked.
If anyone has any ideas on what could cause the issue please share.
The only clue I have is that in the sources tab of the code inspector
there's the content of sw.js (my service worker) but there's nothing to do with it.
I came out that the issue was caused by a cookie called ServiceWorker.
After deleting it everything works fine.

Chrome's Dev console doesn't post console.log("message")when page is loaded from localhost (XAMPP Apache Server)

I am running a simple jQuery code (developing a simple webpage), while following a YouTube jQuery & Ajax tutorial. Half way of the tutorial, I was running the index.html file directly from my PC folder on Google Chrome, and console.log("message") worked fine, posting the "message" on Chrome Dev console.
Getting into Ajax territory, the tut suggests running a local Apache Server with XAMPP.
Here is the problem, as the same code doesn't post anything on Chrome Dev console when the index.html is running from localhost throught XAMPP.
PrtSCR of the page loaded from localhost (left) and from file (right)
After a lot of searching I finally found what the problem was!
It was a browser cache issue! (I use Chrome)
So I disabled Chrome Dev cache, and it works fine!
Anonther solution that I found is Cache Killer extension for Chrome, that clears the browsers cache in every page refresh.

ExtensionInstallSources in Chrome extensions for Enterprise policy

We have google chrome extension that needs to be used inside our organization. We have domains there.
Based on enterprise options the easiest approach for us is to host it on some internal web server, and then add address of that internal site as ExtensionInstallSources option to users PC via Group policies, but this does't work for me.
I've tried both registry and local Group Policy changes by adding Google Chrome adm\admx files.
Here is my registry change:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallSources]
"1"="http://localhost/*"
When i'm checking chrome://policy - it displays that it loaded this settings. But when i open http://localhost/myextension.crx - Chrome still displays an error that extension can't be installed from there...
I'm using 47.0.2526.106 m (64-bit) under Windows 8.1 Enterprise (x64)
What i'm doing wrong here?
I have more complicated option to download chrome source\pdbs, and then try to debug it to get understanding why it's not working but it may take a lot of time, as Chrome can compile for a couple of hours on Windows at first build....
So apparently this registry change just wasn't enough. After debugging chrome source i found why it doesn't work for me. I missed:
The referer MUST be present and it also should be whitelisted. So if i open url for my extension by direct link, then as referer is missing - it won't install it. (Oh Chrome, at least you could say with message about it...). If i have web page that has link to that extension, and it's also whitelisted, then it will work fine.
Second missed point was that extension id MUST be present in ExtensionInstallWhitelist, otherwise Chrome will install it and with 2-3 seconds delay will disable it. But if you have listed it under ExtensionInstallWhitelist, then it will be fine.
So my final registry change for localhost is:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallSources]
"1"="http://localhost/*"
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallWhitelist]
"1"="fhojekmcngnmkdbcoegjdlojgfngkpak"
I found it after long debugging in ExtensionManagement class - https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/extensions/extension_management.cc&q=ExtensionManagement::IsOffstoreInstallAllowed&sq=package:chromium&type=cs&l=148

FileReader API working in jsFiddle, but not from local file

I'm working on a Chrome/Firefox extension which will be using the file API to store files locally. I'm trying to get an example up and running but I'm running into issues which seem to center around Chrome. Can anyone explain why this jsFiddle works fine, but the exact same code, when run from a local file, doesn't work. Please note that it works fine in Firefox, just not in Chrome. Any ideas?
Chrome has unusually restrictive web security; many things, like Ajax, won't work when run locally. This is one of them. You can get around this problem by either using a local websever, like #ephemient suggests, or you can run Chrome in unsafe mode for testing:
chrome.exe --disable-web-security
Yep. Chrome's SOP prevents just about everything in file:// from working[1]. Use a local webserver instead.
If you are using chrome. Start the chrome from command line with the flag
--allow-file-access-from-files
chrome doesn't support for accessing local file without this flag.