Skip to content

'onBeforeRequest' with filter is not working #4

@phanthai12

Description

@phanthai12

My code:

const filter = {
    urls: ['http://abc.com']
}
player.nightmare
.onBeforeRequest(filter, function(detail, callback) {
    callback({
        cancel: true
    });
})
.onErrorOccurred({ urls: ['http://*/*', 'https://*/*'] })
.on('onErrorOccurred', function(details) {
    console.log(details);
    if (details.resourceType == "mainFrame" && details.error == "net::ERR_BLOCKED_BY_CLIENT") {
        console.log("fail to load website: ", details.url);
        player.nightmare.end();
    }
}).goto("https://youtube.com").wait(30000);

it will return error:

{
    "message": "navigation error",
    "code": -20,
    "details": "ERR_BLOCKED_BY_CLIENT",
    "url": "https://youtube.com/"
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions