Skip to content

Commit

Permalink
bypass profy for own site by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Hofstätter committed Feb 20, 2019
1 parent 9822103 commit 2f35755
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ getAsString()
- pdf global
- pdf "pages" predefined + custom
- image global + custom
- bypass_proxy_for_own_site

## templates
html!
Expand Down
1 change: 1 addition & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Name: wkhtmltox
Before: app
---
Grasenhiller\WkHtmlToX:
bypass_proxy_for_own_site: true
Pdf:
options:
global:
Expand Down
6 changes: 6 additions & 0 deletions src/WkFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Assets\FileNameFilter;
use SilverStripe\Assets\Folder;
use SilverStripe\Control\Director;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Environment;
use SilverStripe\View\Requirements;
use SilverStripe\View\SSViewer;
Expand All @@ -23,13 +24,18 @@ function __construct($type) {

/**
* Set the proxy if defined in the environment
* and bypass proxy for own site
*/
public function autoSetProxy() {
$proxy = Environment::getEnv('SS_PROXY');

if ($proxy) {
$this->setOption('proxy', $proxy);
}

if (Config::inst()->get('Grasenhiller\WkHtmlToX', 'bypass_proxy_for_own_site')) {
$this->setOption('bypass-proxy-for', rtrim(str_replace(['http://', 'https://'], ['', ''], Director::absoluteBaseURL()), '/'));
}
}

/**
Expand Down

0 comments on commit 2f35755

Please sign in to comment.