Support remote browsers by removing file:// protocol enforcement #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The current implementation enforces
file://protocol for thetemplate_pathparameter inhtml_to_pic, which prevents the use of remote browsers configured viahtmlrender_connectorhtmlrender_connect_over_cdp. Remote browsers cannot access local file systems through thefile://protocol, making the plugin incompatible with remote deployment scenarios.Solution
This PR removes the hardcoded
file://protocol enforcement and makes the interface flexible to support various URL schemes needed for remote browser scenarios.Changes Made
1.
html_to_picfunctionfile://protocolfile://- Local file paths (existing behavior)http:///https://- Remote URLs (for remote browsers)data:- Data URLs for inline contentabout:blank- Blank page (recommended for pure HTML content)2.
template_to_picfunctionbase_urlfrom thepagesparameter instead of hardcodingfile://{template_path}file://{template_path}whenbase_urlis not providedtemplate_path: Local filesystem path for jinja2 template loadingbase_url: Browser base URL for resolving relative resource paths3. Documentation
Added comprehensive section in README explaining remote browser usage with examples:
4. Tests
test_html_to_pic_with_different_url_schemesto verify support forabout:blankanddata:URLstest_template_to_pic_with_different_base_urlto verify custombase_urlparameter usageBackward Compatibility
✅ Fully backward compatible - All existing code continues to work without modification:
file://URLs by default)Benefits
Fixes the issue raised in the problem statement about adapting data_source methods for remote browser capability.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.