With a chrome extension you can block a request as follows
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
return { cancel: true };
}, {
urls: ["*://localhost/*"]
}, [
"blocking"
]
);
In my case I want to respond to the request within the chrome extension itself without going to the backend. I actually want 2 to do 2 things
1) respond with some data within my extension
2) respond with a 4xx or 5xx
So, in my code example above, canceling doesn't seem to do it, the request is cancelled and nothing is possible anymore. So my question is, how can I respond within my extension with whatever statusCode I want?