diff --git a/server/routes/file.coffee b/server/routes/file.coffee index abb5302e8..8406dd462 100644 --- a/server/routes/file.coffee +++ b/server/routes/file.coffee @@ -3,6 +3,7 @@ fs = require 'fs' request = require 'request' mongoose = require('mongoose') errors = require '../commons/errors' +config = require '../../server_config' module.exports.setup = (app) -> app.all '/file*', (req, res) -> @@ -176,13 +177,17 @@ createPostOptions = (req) -> options clearCloudFlareCacheForFile = (path='/file') -> + unless config.cloudflare.token + console.log 'skipping clearing cloud cache, not configured' + return + request = require 'request' r = request.post 'https://www.cloudflare.com/api_json.html', (err, httpResponse, body) -> if (err) console.error('CloudFlare file cache clear failed:', body) form = r.form() - form.append 'tkn', 'dea38682b209901a014dba2b2702afa5476a0' + form.append 'tkn', config.cloudflare.token form.append 'email', 'scott@codecombat.com' form.append 'z', 'codecombat.com' form.append 'a', 'zone_file_purge' diff --git a/server_config.coffee b/server_config.coffee index ec3c38dfd..7741825cf 100644 --- a/server_config.coffee +++ b/server_config.coffee @@ -4,6 +4,8 @@ config.unittest = process.argv.indexOf("--unittest") > -1 config.port = process.env.COCO_PORT or process.env.COCO_NODE_PORT or 3000 config.ssl_port = process.env.COCO_SSL_PORT or process.env.COCO_SSL_NODE_PORT or 3443 +config.cloudflare = + token: process.env.COCO_CLOUDFLARE_API_KEY or '' config.mongo = port: process.env.COCO_MONGO_PORT or 27017