Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support capturing assets from allowed hostnames #320

Merged
merged 4 commits into from
Aug 7, 2019

Conversation

timhaines
Copy link
Contributor

@timhaines timhaines commented Aug 7, 2019

Adds support for allowed hostnames that assets should be captured from.

If a hostname is specified, any requests to assets on that hostname will be captured, and they'll be uploaded to Percy's API as snapshot resources. During rendering time, http requests to the captured asset's url will be hijacked, and the captured resource served.

Hostnames can be provided either with the -allowed-hostname or -h flag, or they can be specified in the .percy.yml file as an array under agent -> asset-discovery -> allowed-hostnames.

The main function is tested with the new alternate-hostname integration test. It loads a vue.svg file from a hostname of localhost.me. Localhost.me resolves to 127.0.0.1, so we can serve it from our local dev/CI environment, and be sure that the captured asset is being served in production.

Note: requests to https assets won't be successfully highjacked in our rendering environment yet, but this PR should include the appropriate support for capturing them to our @percy/agent based SDKs.

@timhaines timhaines changed the title Add support for capturing assets from multiple allowed hostnames feat: Support capturing assets from allowed hostnames Aug 7, 2019
@timhaines timhaines marked this pull request as ready for review August 7, 2019 04:17
Copy link
Contributor

@djones djones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍍 LGTM

@@ -1,5 +1,4 @@
import * as cheerio from 'cheerio'
import * as fs from 'fs'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

it, and we start the integration tests by specifying localhost.me as an allowed-hostname
with the -h flag.
</p>
<img src="http://localtest.me:8000/vue.svg">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious how this works in CI? Are we editing a host file to make this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Robdel12 no, localtest.me's dns entry points to 127.0.0.1. So in CI the node server we spin up that listens to 127.0.0.01:8000 works just the same way it does locally, with no configuration needed.

@timhaines timhaines merged commit c3fb8ac into master Aug 7, 2019
@delete-merged-branch delete-merged-branch bot deleted the multi-hostname-support branch August 7, 2019 14:49
djones pushed a commit that referenced this pull request Aug 7, 2019
# [0.10.0](v0.9.2...v0.10.0) (2019-08-07)

### Features

* Support capturing assets from allowed hostnames ([#320](#320)) ([c3fb8ac](c3fb8ac))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants