Steps to reproduce
Edge extensions (unlike Chrome, Safari and Firefox) don’t properly handle XMLHttpRequest calls to localhost in a background script.
- Run a web server on localhost (127.0.0.1 on port 8000) (an easy way to do this with python 3 is:
python -m http.server 8000
- Load the attached extension in Edge
- Open the background script for debugging
- Go to https://developer.microsoft.com/en-us/windows/bridges/hosted-web-apps and hit refresh if necessary (this just kicks off the content script and gets things going)
- In the background debugger, you would expect to see these console messages:
- Note that instead only UNSENT and OPENED messages are seen and status doesn’t change from 0
- To see the script working with a non-localhost address, comment out this line in the background-script.js file:
var url = 'http://127.0.0.1:8000';
and uncomment the line before:
//var url = 'https://developer.mozilla.org:443';
- Reload the extension and refresh the page and everything works as expected (for the non-localhost page)
Comments and activity
- Microsoft Edge Team
Changed Assigned To to “Steven K.”
Changed Assigned To to “Akshay P.”
Changed Status to “Confirmed”
Changed Assigned To from “Akshay P.” to “Mahesh J.”
I ran into this issue while developing my own extension, and it was frustrating to say the least. It turns out that you need to ensure that edge is added to the loopback exempt list with the command "CheckNetIsolation LoopbackExempt -a -n="Microsoft.MicrosoftEdge_8wekyb3d8bbwe", documented here - https://developer.microsoft.com/en-us/microsoft-edge/platform/faq/#how-can-i-debug-localhost. To remove it from the exempt list (for security reasons), use the command CheckNetIsolation LoopbackExempt -d -n="Microsoft.MicrosoftEdge_8wekyb3d8bbwe".
A recommendation for this issue is to add Edge to the exemption list once the developer has selected “Enable extension developer features…” in about:flags.
Small note, is that those commands,
CheckNetIsolation LoopbackExempt -a -n="Microsoft.MicrosoftEdge_8wekyb3d8bbweand
CheckNetIsolation LoopbackExempt -d -n="Microsoft.MicrosoftEdge_8wekyb3d8bbwe, should be run in a Powershell prompt in Administrator mode.