jhildenbiddle / get-css-data

A micro-library for collecting stylesheet data from link and style nodes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xmlhttprequest not support file protocol

H-TWINKLE opened this issue · comments

if the link protocol is file,such as “file:///E:/a.css”
will be blocked,
error meesage is " origin 'null' has been blocked by cors policy: cross origin requests are only support protocol schemes: http ,data,chrome,chrome-extension,chrome-untrustef,https"

html link is

Thanks.

This is a security restriction enforced by browsers (like Chrome) to prevent web content from accessing your local file system. The are only two ways the ponyfill can access stylesheets via the file:// protocol:

  1. Modify the security settings in your browser to allow local file access. Before you do so, understand the security risks you are introducing.
  2. Use a browser that allows local file access. Firefox used to allow this, but I'm not sure if it still does.
  3. Host your stylesheet on a server so it can be accessed via http/https. For example, you could host the stylesheet in a GitHub repo at no charge.

Hope this helps. :)