mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-03 12:27:30 -05:00
ca067fdc5e
We’ve now exceeded our max number of characters for a condition in the Fastly API, and we need to make it larger to accommodate regex conditionals that can match on any of the routes in www currently. This fixes the issue by moving the conditions – and the states that are affected by it, like setting the backend or cache ttls – to two custom vcl files that are updated via the Fastly API. One is for the `vcl_rev` config, and one is for the `vcl_fetch` config.
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
var fastly = require('../../bin/lib/fastly-extended');
|
|
var tap = require('tap');
|
|
|
|
tap.test('testSetBackend', function (t) {
|
|
var backend = fastly.setBackend('wemust', 'goback', 'marty');
|
|
t.equal(backend, '' +
|
|
'if (marty) {\n' +
|
|
' set req.backend = wemust;\n' +
|
|
' set req.http.host = \"goback\";\n' +
|
|
'}\n'
|
|
);
|
|
});
|
|
|
|
tap.test('testSetForward', function (t) {
|
|
var forward = fastly.setForwardHeaders('alwaysforward');
|
|
t.equal(forward, '' +
|
|
'if (alwaysforward) {\n' +
|
|
' if (!req.http.Fastly-FF) {\n' +
|
|
' if (req.http.X-Forwarded-For) {\n' +
|
|
' set req.http.Fastly-Temp-XFF = req.http.X-Forwarded-For ", " client.ip;\n' +
|
|
' } else {\n' +
|
|
' set req.http.Fastly-Temp-XFF = client.ip;\n' +
|
|
' }\n' +
|
|
' } else {\n' +
|
|
' set req.http.Fastly-Temp-XFF = req.http.X-Forwarded-For;\n' +
|
|
' }\n' +
|
|
' set req.grace = 60s;\n' +
|
|
' return(pass);\n' +
|
|
'}\n'
|
|
);
|
|
t.end();
|
|
});
|
|
|
|
tap.test('testSetTTL', function (t) {
|
|
var ttl = fastly.setResponseTTL('itsactuallyttyl');
|
|
t.equal(ttl, '' +
|
|
'if (itsactuallyttyl) {\n' +
|
|
' set beresp.ttl = 0s;\n' +
|
|
' set beresp.grace = 0s;\n' +
|
|
' return(pass);\n' +
|
|
'}\n'
|
|
);
|
|
});
|