zsajjad / react-facebook-pixel

React JS wrapper for Facebook's Pixel
MIT License
233 stars 86 forks source link

Not working on localhost. #73

Closed mfaizan1 closed 3 years ago

mfaizan1 commented 3 years ago

I used minimal documentation code

const advancedMatching = {}; // optional, more info: https://developers.facebook.com/docs/facebook-pixel/advanced/advanced-matching
const options = {
  autoConfig: true, // set pixel's autoConfig. More info: https://developers.facebook.com/docs/facebook-pixel/advanced/
  debug: false, // enable logs
};
ReactPixel.init('FACEBOOKPIXELID', advancedMatching, options);

ReactPixel.pageView();
ReactPixel.revokeConsent();

and granting consent on button click

        <button onClick={ReactPixel.grantConsent}>
          Accept cookies
        </button>

but my request is being blocked

request

request expanded

am i supposed to run localhost using ssl with ngrok with ?

mfaizan1 commented 3 years ago

it is not issue with this library but with browsers policy, by default browsers don't allow https requests from website running on http, since localhost was on http so that was causing the issue to make it work on local host please follow this

https://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome