mirror of
https://github.com/d0zingcat/cors-anywhere.git
synced 2026-05-13 15:09:25 +00:00
Add handleInitialRequest option to support #301
The custom filtering logic is not part of the public repository, to keep the project clean.
This commit is contained in:
@@ -256,6 +256,7 @@ function parseURL(req_url) {
|
||||
// Request handler factory
|
||||
function getHandler(options, proxy) {
|
||||
var corsAnywhere = {
|
||||
handleInitialRequest: null, // Function that may handle the request instead, by returning a truthy value.
|
||||
getProxyForUrl: getProxyForUrl, // Function that specifies the proxy to use
|
||||
maxRedirects: 5, // Maximum number of redirects to be followed.
|
||||
originBlacklist: [], // Requests from these origins will be blocked.
|
||||
@@ -310,6 +311,10 @@ function getHandler(options, proxy) {
|
||||
|
||||
var location = parseURL(req.url.slice(1));
|
||||
|
||||
if (corsAnywhere.handleInitialRequest && corsAnywhere.handleInitialRequest(req, res, location)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!location) {
|
||||
// Invalid API call. Show how to correctly use the API
|
||||
showUsage(corsAnywhere.helpFile, cors_headers, res);
|
||||
|
||||
Reference in New Issue
Block a user