react-snap icon indicating copy to clipboard operation
react-snap copied to clipboard

Add support for allowed third party domains

Open harrygreen opened this issue 6 years ago • 5 comments

With skipThirdPartyRequests: true, calls to our own APIs are blocked too . I added an allowedThirdPartyDomains array to the options config, to act as a whitelist.

Example usage:

// package.json
"reactSnap": {
  "skipThirdPartyRequests": true,
  "allowedThirdPartyDomains": ["https://api.pizzahut.io"]
}

Any request url starting with https://api.pizzahut.io will not be skipped, e.g. https://api.pizzahut.io/v1/huts/?sector=uk-1,uk-2


We love using react-snap on https://www.pizzahut.co.uk/ and https://www.pizzahut.fr/. Thank you so much for your work, @stereobooster.

harrygreen avatar Jul 14 '18 14:07 harrygreen

Hi Harry. Thank you for contribution. Can you please add test for this feature?

stereobooster avatar Jul 14 '18 14:07 stereobooster

Hi @stereobooster - thanks, I'm happy to help you with this. I'll try to write a test inside run.test.js with a similar level of integration as the other.

Ideally I'd like to break out the function inside page.on("request", request => {...} in skipThirdPartyRequests, and unit test that in isolation.

harrygreen avatar Jul 14 '18 17:07 harrygreen

@stereobooster I updated with some unit tests.

We didn't end up needing this feature at Pizza Hut, but I'm happy to help get it live if you'd still like it.

--

Actually, we do need it! Would you like me to do anything else before merging?

harrygreen avatar Aug 11 '18 20:08 harrygreen

Any movement on this? My project uses a CDN to construct the all the routes and this would be a huge help.

mercurjl avatar Dec 18 '18 01:12 mercurjl

this could still be great

ml242 avatar Jul 07 '21 20:07 ml242