jhen0409 / react-chrome-extension-boilerplate

Boilerplate for Chrome Extension React.js project
MIT License
2.14k stars 388 forks source link

inject.js not working on fresh install #70

Closed awwester closed 7 years ago

awwester commented 7 years ago

Great boilerplate project, really helps get of the ground running for someone new to extensions.

I have the popup working fine but am having issues with the inject portion on github.

In the docs it states simply: "The inject script is being run by chrome/extension/background/inject.js. A simple example will be inject bottom of page(https://github.com/*) if you visit."

I would think that if my popup is working fine I've done the install and setup correctly, but nothing happens when i got to any link on github. Is there some setup that I might be missing and is also missing from the docs to get inject to work correctly?

Also when I try to console log in inject.js to debug there's nothing gets logged. From what I've read injected/content scripts should log to the normal browser console.

awwester commented 7 years ago

Just noticed too when I go into chrome://extensions and inspect views > background.html I'm seeing a CORS error with inject.js

Fetch API cannot load http://localhost:3000/js/inject.bundle.js. 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'chrome-extension://dlbkhleokpkjcadeelpcbafoaeopbkbf' is therefore not allowed access. 
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the 
resource with CORS disabled.
jhen0409 commented 7 years ago

Fixed in https://github.com/jhen0409/react-chrome-extension-boilerplate/commit/c58130bfe6465fef280db6cfc23365e5e9c6d276, thanks for report! 👍