mirror of
https://github.com/d0zingcat/cors-anywhere.git
synced 2026-05-13 15:09:25 +00:00
Do not send Access-Control-Max-Age header if corsMaxAge is 0 (default)
This commit is contained in:
@@ -107,8 +107,7 @@ proxy requests. The following options are supported:
|
||||
Example: `["cookie"]`
|
||||
* dictionary of lowercase strings `setHeaders` - Set headers for the request (overwrites existing ones).
|
||||
Example: `{"x-powered-by": "CORS Anywhere"}`
|
||||
* number `corsMaxAge` - If set, an Access-Control-Max-Age request header with this value (in seconds) will be added.
|
||||
Defaults to 0.
|
||||
* number `corsMaxAge` - If set, an Access-Control-Max-Age request header with this value (in seconds) will be added.
|
||||
Example: `600` - Allow CORS preflight request to be cached by the browser for 10 minutes.
|
||||
* string `helpFile` - Set the help file (shown at the homepage).
|
||||
Example: `"myCustomHelpText.txt"`
|
||||
|
||||
@@ -53,7 +53,7 @@ function isValidHostName(hostname) {
|
||||
function withCORS(headers, request) {
|
||||
headers['access-control-allow-origin'] = '*';
|
||||
var corsMaxAge = request.corsAnywhereRequestState.corsMaxAge;
|
||||
if (corsMaxAge != null) {
|
||||
if (corsMaxAge) {
|
||||
headers['access-control-max-age'] = corsMaxAge;
|
||||
}
|
||||
if (request.headers['access-control-request-method']) {
|
||||
|
||||
@@ -50,7 +50,6 @@ describe('Basic functionality', function() {
|
||||
.get('/')
|
||||
.type('text/plain')
|
||||
.expect('Access-Control-Allow-Origin', '*')
|
||||
.expect('Access-Control-Max-Age', '0')
|
||||
.expect(200, helpText, done);
|
||||
});
|
||||
|
||||
@@ -92,7 +91,6 @@ describe('Basic functionality', function() {
|
||||
request(cors_anywhere)
|
||||
.get('/example.com')
|
||||
.expect('Access-Control-Allow-Origin', '*')
|
||||
.expect('Access-Control-Max-Age', '0')
|
||||
.expect('x-request-url', 'http://example.com/')
|
||||
.expect(200, 'Response from example.com', done);
|
||||
});
|
||||
@@ -841,9 +839,7 @@ describe('Access-Control-Max-Age set', function() {
|
||||
|
||||
describe('Access-Control-Max-Age not set', function() {
|
||||
before(function() {
|
||||
cors_anywhere = createServer({
|
||||
corsMaxAge: null,
|
||||
});
|
||||
cors_anywhere = createServer();
|
||||
cors_anywhere_port = cors_anywhere.listen(0).address().port;
|
||||
});
|
||||
after(stopServer);
|
||||
|
||||
Reference in New Issue
Block a user