Fix the error for SPFX development 'Access to XMLHttpRequest at ... from origin ... has been blocked by CORS policy'
While the development SPFX for SharePoint 2019 once the loading of the webpart at 'workbench.aspx' page stopped. SharePoint server is installed at my virtual machine, the development of SPFX is local. At first I totally could not understand what's wrong. But soon started to look for the reason.
In Chrome (and Edge) consoles there was an error:
Failed to load resource: net::ERR_FAILED
Access to XMLHttpRequest at 'http://localhost:4321/temp/manifests.js' from origin 'http://win-blablabla' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local
.
I need this tool only for the development and I didn't want to set up certificates and add trusted zones to avoid CORS. And I found a solution. My advice is to turn it on only on time of the development, after that to return to defaults.
In Chrome address bar open the URL:
chrome://flags/#block-insecure-private-network-requests
and set to 'Disabled' option 'Block insecure private network requests'
After changing the value, relaunch the browser.