ForceCORS
ForceCORS copied to clipboard
Feature request to pass HTTP_ORIGIN with CORS
Chris,
I added the feature. The issue with the response it that you don't have the request object: http://sysmagazine.com/posts/166539/
So I did the following:
- wrapped the background.js in a method - to avoid global scope (this reduces warnings by ugilfyjs)
- added a requestIds array / stack that caches the request data. I allow 10s before the request is GC'd
- added a onBeforeSendHeaders handler - to find the request data
- moved the onErrorOccurred to onErrorOccurredHandler to continue with the same logic and not stack the event handler on every change
- added the logic to change HTTP_ORIGIN to "Origin/Referer/*" in that order
- tested it with my garmin.com.js plugin - works great!!
requestIds = requestIds.filter(function(elem) {
if (elem.requestId === requestId) {
request = elem;
}
return (elem.expiration < now && elem.requestId !== requestId);
});
This will find the element and filter expired ones and the current one ...
This may be better (less compares):
requestIds = requestIds.filter(function(elem) {
if (elem.requestId === requestId) {
request = elem;
return false; // remove
}
return (elem.expiration < now); // true -keep- if not expired
});
~~Thanks! I found a bug with my filter... updating code now.~~
Logic was ok ... filter is weird as it true (keeps) and false (removes)