Skip to content

Commit e1591fc

Browse files
committed
[Utils] Do not allow prerender outside of HTML parser (#611)
* do not use `prerender` for head and content type requests * `prevent_prerender` for `oembed` and `request` * send additional params to allow iframes in prerender * better support for PRERENDER_URL * use prerender only for htmlparser * fix obsolete code * fix obsolete code
1 parent 0ff5423 commit e1591fc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/plugins/system/htmlparser/htmlparser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default {
2020

2121
var options2 = {...options, ...{
2222
followRedirect: !!options.followHTTPRedirect,
23-
reuseCookies: !!options.followHTTPRedirect
23+
reuseCookies: !!options.followHTTPRedirect,
24+
allowPrerender: true
2425
}};
2526

2627
options.registerFetch({

lib/utils.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ export function prepareRequestOptions(request_options, options) {
9595

9696
var proxy = (options && options.proxy) || getCustomProxyForUri(uri, options);
9797
if (proxy) {
98-
if (proxy.prerender && CONFIG.PRERENDER_URL) {
98+
if (proxy.prerender && CONFIG.PRERENDER_URL && options?.allowPrerender) {
9999
request_options.uri = CONFIG.PRERENDER_URL + encodeURIComponent(uri);
100100

101+
// Use string `proxy.prerender` as additional prerender param.
102+
if (typeof proxy.prerender === 'string') {
103+
request_options.uri += (request_options.uri.indexOf('?') > -1 ? '&' : '?' ) + `prerender=${proxy.prerender}`;
104+
}
105+
101106
} else if (proxy.proxy && CONFIG.PROXY_URL) {
102107
request_options.uri = /{url}/.test(CONFIG.PROXY_URL)
103108
? CONFIG.PROXY_URL.replace(/{url}/, encodeURIComponent(uri))
@@ -1230,7 +1235,7 @@ var getUriStatusPrivate = function(uri, options, cb) {
12301235
},
12311236
timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT,
12321237
follow: CONFIG.MAX_REDIRECTS
1233-
})
1238+
});
12341239

12351240
try {
12361241
fetchStream(request_options)

0 commit comments

Comments
 (0)