mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 21:04:34 +00:00
redirect to external URLs - closes #490
This commit is contained in:
@@ -50,6 +50,20 @@ export class AppRunner {
|
||||
}
|
||||
});
|
||||
|
||||
await this.page.setRequestInterception(true);
|
||||
|
||||
this.page.on('request', interceptedRequest => {
|
||||
if (/example\.com/.test(interceptedRequest.url())) {
|
||||
interceptedRequest.respond({
|
||||
status: 200,
|
||||
contentType: 'text/html',
|
||||
body: `<h1>external</h1>`
|
||||
});
|
||||
} else {
|
||||
interceptedRequest.continue();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
page: this.page,
|
||||
base: `http://localhost:${this.port}`,
|
||||
|
||||
Reference in New Issue
Block a user